﻿using System; 
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.OracleClient;
using System.Data.SqlClient; 
using System.Collections;
using CIMCService;
using System.Net;
using System.Net.Sockets; 
using System.Collections.Specialized;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService 
{
    static private string g_usespace;
    public Service () {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
        System.Configuration.AppSettingsReader g_getspace = new System.Configuration.AppSettingsReader();
        g_usespace = ((string)(g_getspace.GetValue("userspace", typeof(string))));
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
//////////////////////////////////// ORACLE数据库/////////////////////////////////////////////////////////
    //得到服务器的IP地址
    [WebMethod]
    public string oracle_get_ip(string str_inv,int i_no)
    {
        string str_mac, str_ip, str_return;
        OracleCommand command;
        DataSet ds;
        command = new OracleCommand();
        ds = new DataSet();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            str_mac = "select trim(id_data) from " + g_usespace + ".sys_parameter where inv_org = '" + str_inv + "' and id = " + i_no.ToString().Trim();
            command.CommandText = str_mac;
            ds = dbCenter.ExecuteQuery(command);
            if (ds.Tables[0].Rows.Count > 0) //说明找到 
            {
                str_mac = ds.Tables[0].Rows[0][0].ToString().Trim();
                str_ip = "";
                IPAddress[] localIPs;
                localIPs = Dns.GetHostAddresses(str_mac);
                StringCollection IpCollection = new StringCollection();
                foreach (IPAddress ip in localIPs)
                {
                    //根据AddressFamily判断是否为ipv4,如果是InterNetWork则为ipv6
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        str_ip = ip.ToString().Trim();
                        break;
                    }
                }
                if (str_ip == "")
                {
                    str_return = "";
                }
                else
                {
                    str_return = str_mac.Trim() + str_ip.Trim();
                }
            }
            else //没有找到 
            {
                str_return = "";
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_return;
    }

    //提取系统登录信息
    [WebMethod]
    public DataSet oracle_get_logininfor(string strsql)
    {
        OracleCommand command;
        DataSet ds;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            ds = dbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return ds;
    }

    //执行通用select语句返回字符串
    [WebMethod]
    public string oracle_exec_selectstring(string strsql)
    {
        OracleCommand command;
        DataSet ds;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            ds = dbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        if (ds.Tables[0].Rows.Count > 0)
            return ds.Tables[0].Rows[0][0].ToString().Trim();
        else
            return "";
    }

    //执行通用select语句返回整型
    [WebMethod]
    public Int32 oracle_exec_selectint(string strsql)
    {
        OracleCommand command;
        DataSet ds;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            ds = dbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        if (ds.Tables[0].Rows.Count > 0)
            return System.Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString().Trim());
        else
            return 0;
    }

    //执行通用select语句返回数据集
    [WebMethod]
    public DataSet oracle_exec_selectsql(string strsql)
    {
        OracleCommand command;
        DataSet ds;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            ds = dbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        { 
            dbCenter.CloseConnection();
        }
        return ds;
    }

    //执行通用command语句
    [WebMethod]
    public void oracle_exec_commandsql(string strsql)
    {
        OracleCommand command;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    /// <summary>
    /// 执行通用command语句,返回影响的行数
    /// </summary>
    /// <param name="strsql"></param>
    [WebMethod]
    public int  oracle_exec_command(string strsql)
    {
        int resultCnt = 0;
        OracleCommand command;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            resultCnt= dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return resultCnt;
    }

    //执行通用command语句
    [WebMethod]
    public string oracle_exec_commandsqltest(string strsql)
    {
        return strsql;
    }


    //批量更新数据库
    [WebMethod]
    public void oracle_refresh_db(DataSet dtst, string strsql)
    {
        OracleCommand command;
        command = new OracleCommand(strsql);
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.updatedatabaser(command, dtst);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //批量更新数据库再加一条sql语句
    [WebMethod]
    public void oracle_insert_dataset(string str_insert,DataSet dtst, string strsql)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = str_insert;
            dbCenter.ExecuteNonQuery(command);
            command.CommandText = strsql; 
            dbCenter.updatedatabaser(command, dtst);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //得到相应的单据号
    [WebMethod]
    public Int32 oracle_get_accountno(string s_org, string straccount)
    {
        string s_str;
        Int32 r_int;
        OracleCommand command;
        DataSet ds;
        command = new OracleCommand();
        ds = new DataSet();
        straccount = straccount.ToUpper();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction(); 
            //先锁账号表
            s_str = "update "+g_usespace+".mst_account set page_no = page_no where inv_org = '"+s_org+"' and upper(bill_id) = '" + straccount + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command); 
            //得到相应的帐号 
            s_str = "select page_no from " + g_usespace + ".mst_account where inv_org = '" + s_org + "' and upper(bill_id) = '" + straccount + "'";
            command.CommandText = s_str;
            ds = dbCenter.ExecuteQuery(command); 
            if (ds.Tables[0].Rows.Count > 0) //说明找到 
            {
                r_int = System.Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString().Trim());
                r_int = r_int + 1;
            }
            else //没有找到 
            {
                r_int = 0;
            }
            //更新帐号表
            s_str = "update " + g_usespace + ".mst_account set page_no = page_no + 1 where inv_org = '" + s_org + "' and upper(bill_id) = '" + straccount + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return r_int;
    }

    //执行多条sql更新或者插入的语句
    [WebMethod]
    public void oracle_exec_mutilsql(string[] str_array)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //先锁账号表
            for (int i = 0; i < str_array.Length; i++)
            {
                if (str_array[i].ToString().Trim() != "")
                {
                    command.CommandText = str_array[i].ToString().Trim();
                    dbCenter.ExecuteNonQuery(command);
                } 
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        } 
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    #region 订单管理的函数
    //订单计划做成 
    [WebMethod]
    public string oracle_make_plan_asnno(DataSet ds_asn, string str_userid)
    {
        DataView dv_asn;
        DataTable dt_asn;
        string ls_middle, str_supply, str_supply_old, str_asnno, str_command;
        string str_first_no;
        string str_lot6, str_lot8;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        ls_middle = "";
        str_supply = "";
        str_supply_old = "";
        str_asnno = "";
        str_first_no = "";
        try
        {   
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            dv_asn = ds_asn.Tables[0].DefaultView;
            dv_asn.Sort = "supply,asn_line_no";
            dt_asn = dv_asn.ToTable(); 
            if (dt_asn.Rows.Count > 0)  //有数据进行单据号的拆分
            {
                for (int i = 0; i < dt_asn.Rows.Count; i++)
                {
                    str_supply = dt_asn.Rows[i]["supply"].ToString().Trim();
                    if (str_supply.Trim() != str_supply_old.Trim()) //说明不相等,插入表头
                    {
                        //得到单据号
                        str_asnno = "AN" + oracle_get_accountno(dt_asn.Rows[i]["inv_org"].ToString().Trim(), "ASN_NO").ToString("00000000");
                        //插入表头
                        if (i == 0)
                        {
                            str_first_no = str_asnno;
                        }
                        str_command = "insert into " + g_usespace + ".asn_order_header(	inv_org,	consignor,	asn_no,		customer_order_no," +
                                                                                   "eas_order,	contract_no,	order_day,	asn_type," +
                                                                                   "supply,		supply_country,	supply_address,	supply_city," +
                                                                                   "supply_province,	supply_postalcode,	supply_phone,	carrier," +
                                                                                   "carrier_address,	carrier_postalcode,	carrier_phone,	ship_no," +
                                                                                   "fly_no,		vehicle_no,	load_place,	discharge_place," +
                                                                                   "deliver_place,	in_tax,		out_tax,	arrive_plan_day," +
                                                                                   "arrive_deadline,	arrive_day,	asn_status,	arrive_status," +
                                                                                   "colse_day,	colser,		book_status," +
                                                                                   "door,		booker,		buyer,		from_inv_org," +
                                                                                   "so_no,		standby_1,	standby_2,	standby_3," +
                                                                                   "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                   "standby_8,	standby_9,	applier,	ld_dist," +
                                                                                   "memo2,		memo,        main_dist,	made_time,	maker) " +
                                                                           "select a.inv_org,	a.consignor,	'" + str_asnno + "',customer_order_no," +
                                                                                   "'',	'', to_char(sysdate,'YYYY.MM.DD'),	asn_type," +
                                                                                   "trim(b.consignor),		b.country,	b.business_address,	b.city," +
                                                                                   "b.province,	b.postalcode,	b.telephone,	''," +
                                                                                   "'',	'',	'',	''," +
                                                                                   "'',		'',	'',	''," +
                                                                                   "'',	17,		17,	to_char(sysdate + 1,'YYYY.MM.DD')," +
                                                                                   "'',	'',	'0',	'0'," +
                                                                                   "'',	'',		'1'," + 
                                                                                   "'',		'',		buyer,		''," + 
                                                                                   "'',		'',	'0',	''," +
                                                                                   "1,	0,	'',	''," +
                                                                                   "'',	'',	applier,	'0'," +
                                                                                   "'',		'',       'A',	sysdate,	'" + str_userid + "' " +
                                                                       "from " + g_usespace + ".asn_order_make a," + g_usespace + ".mst_customer b " +
                                                                       "where a.inv_org = b.inv_org and trim(a.supply) = trim(b.consignor) and b.supply_flag = '1' and a.happen_day = '" + dt_asn.Rows[i]["happen_day"].ToString().Trim() + "'" +
                                                                       " and a.inv_org = '" + dt_asn.Rows[i]["inv_org"].ToString().Trim() + "' and a.consignor = '" + dt_asn.Rows[i]["consignor"].ToString().Trim() + "' and a.asn_line_no = " + dt_asn.Rows[i]["asn_line_no"].ToString().Trim();
                        command.CommandText = str_command;
                        dbCenter.ExecuteNonQuery(command);
                        str_supply_old = str_supply;
                    }
                    //插入明细  
                    //2014.08.21  为了川山甲新增的
                    if (dt_asn.Rows[i]["asn_type"].ToString().Trim() == "3")  //说明是寄售
                    {
                        str_lot6 = "1_川山甲";  
                    }
                    else
                    {
                        str_lot6 = "0_格瑞夫";
                    }

                    if (dt_asn.Rows[i]["asn_type"].ToString().Trim() == "6")  //说明返修
                    {
                        str_lot8 = "1_返修";
                    }
                    else
                    {
                        str_lot8 = "0_不是返修";
                    }
                    str_command = "insert into " + g_usespace + ".asn_order_detail(	inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                   "eas_order,	order_line_no,	sku,		pack_code," +
                                                                                   "order_qty_m,	order_qty_s,	present_qty_m,	present_qty_s," +
                                                                                   "order_price,	order_unit,	cubage,		gross_weight," +
                                                                                   "net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s," +
                                                                                   "receive_present_qty_m,	receive_present_qty_s,	main_sub_flag,	convert_modulus," +
                                                                                   "receive_day,	receive_status,	lot_attribute1,	lot_attribute2," +
                                                                                   "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                                   "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                                   "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                   "lot_attribute15,	standby_1,	standby_2,	standby_3," +
                                                                                   "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                   "tax_dist,	doc_link,	memo,		main_dist,made_time,	maker) " +
                                                                           "select inv_org,	consignor,	'" + str_asnno + "',		asn_line_no," +
                                                                                   "'',	0,	sku,		pack_code," +
                                                                                   "order_qty_m,	order_qty_s,	0,	0," +
                                                                                   "order_price,	order_unit,	cubage,		gross_weight," +
                                                                                   "net_weight,	shelflife_day,	0,	0," +
                                                                                   "0,	0,	main_sub_flag,	convert_modulus," +
                                                                                   "'',	'0',	lot_attribute1,	lot_attribute2," +
                                                                                   "lot_attribute3,	lot_attribute4,	lot_attribute5,	'" + str_lot6.Trim() + "'," +
                                                                                   "lot_attribute7,	'" + str_lot8.Trim() + "',	lot_attribute9,	lot_attribute10," +
                                                                                   "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                   "lot_attribute15,	'0',	'',	''," +
                                                                                   "'',	'',	0,	0," +
                                                                                   "lot_attribute3,	'',	memo,		'A' ,sysdate,	'" + str_userid + "' " +
                                                                       "from " + g_usespace + ".asn_order_make " +
                                                                       "where happen_day = '" + dt_asn.Rows[i]["happen_day"].ToString().Trim() + "'" +
                                                                       " and inv_org = '" + dt_asn.Rows[i]["inv_org"].ToString().Trim() + "' and consignor = '" + dt_asn.Rows[i]["consignor"].ToString().Trim() + "' and asn_line_no = " + dt_asn.Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = str_command;
                    dbCenter.ExecuteNonQuery(command);
                    //修改状态是做成
                    str_command = "update " + g_usespace + ".asn_order_make set receive_status = '3',update_time = sysdate,updater = '" + str_userid + "' where happen_day = '" + dt_asn.Rows[i]["happen_day"].ToString().Trim() + "'" +
                                                                       " and inv_org = '" + dt_asn.Rows[i]["inv_org"].ToString().Trim() + "' and consignor = '" + dt_asn.Rows[i]["consignor"].ToString().Trim() + "' and asn_line_no = " + dt_asn.Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = str_command;
                    dbCenter.ExecuteNonQuery(command);
                } 
            }
            dbCenter.Commit();
            ls_middle = str_first_no;
        }
        catch (System.Exception ee)
        { 
            ls_middle = ee.Message.ToString().Trim();
            dbCenter.Rollback();
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return ls_middle.Trim();
    }

    //删除整张订单信息，存在表头和明细，所以要在一个事物里面删除
    [WebMethod]
    public void oracle_del_asnno(string s_org, string str_sto,string str_asnh)
    {
        string s_str;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //先删除明细
            s_str = "delete " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor ='" + str_sto + "' and asn_no ='" + str_asnh + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //在删除表头
            s_str = "delete " + g_usespace + ".asn_order_header where inv_org = '"+s_org+"' and consignor ='" + str_sto + "' and asn_no ='" + str_asnh + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //拆分订单
    [WebMethod]
    public void oracle_exec_proc_bom(string s_org, string s_consignor, string s_asn_no, string s_sku, decimal d_ordm, decimal d_fordm, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORACLE_SPLIT_BOM");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_asn_no", OracleType.Char, 20);
            command.Parameters["sp_asn_no"].Value = s_asn_no;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_ordm", OracleType.Number, 16);
            command.Parameters["sp_ordm"].Value = d_ordm;
            command.Parameters.Add("sp_fordm", OracleType.Number, 16);
            command.Parameters["sp_fordm"].Value = d_fordm;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //拆板存储过程
    [WebMethod]
    public void oracle_exec_proc_split(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORACLE_PALLET_SPLIT");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_flag", OracleType.VarChar, 100);
            command.Parameters["sp_flag"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //新拆板存储过程
    [WebMethod]
    public string oracle_exec_proc_split_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORACLE_PALLET_SPLIT_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //重新拆板存储过程
    [WebMethod]
    public void oracle_exec_proc_resplit(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, int i_qty, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORACLE_RESPLIT");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_qty", OracleType.Int32);
            command.Parameters["sp_qty"].Value = i_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_flag", OracleType.VarChar, 100);
            command.Parameters["sp_flag"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //新重新拆板存储过程
    [WebMethod]
    public string oracle_exec_proc_resplit_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, int i_qty, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORACLE_RESPLIT_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_qty", OracleType.Int32);
            command.Parameters["sp_qty"].Value = i_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //PC机上的收货确认新的流程
    [WebMethod]
    public string oracle_confirm_asnno_new(string s_org, DataSet ds_asn, int i_receive_count, string str_userid)
    {
        int i_rec_count;
        string ls_middle, s_str, str_lot;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (i_receive_count <= 0)
            {
                //得到收货次数
                s_str = "select nvl(max(to_number(standby_5)),0) + 1 from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no = '" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
                i_rec_count = oracle_exec_selectint(s_str);
            }
            else
            {
                i_rec_count = i_receive_count;
            }
            //调用存储过程进行收货
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                if (System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) > 0) //说明有收货数
                {
                    //设置15个批次属性
                    str_lot = ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + ";" +
                              ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + ";" +
                              ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + ";" +
                              ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + ";";
                    //开始调用存储过程
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_RECEIVE_NEW";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = s_org;
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_qtym", OracleType.Number, 16);
                    command.Parameters["sp_qtym"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim());
                    command.Parameters.Add("sp_qtys", OracleType.Number, 16);
                    command.Parameters["sp_qtys"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim());
                    command.Parameters.Add("sp_fqtym", OracleType.Number, 16);
                    command.Parameters["sp_fqtym"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim());
                    command.Parameters.Add("sp_fqtys", OracleType.Number, 16);
                    command.Parameters["sp_fqtys"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim());
                    command.Parameters.Add("sp_cubage", OracleType.Number, 10);
                    command.Parameters["sp_cubage"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim());
                    command.Parameters.Add("sp_gross", OracleType.Number, 10);
                    command.Parameters["sp_gross"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim());
                    command.Parameters.Add("sp_net", OracleType.Number, 10);
                    command.Parameters["sp_net"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim());
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = ds_asn.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("sp_lotstr", OracleType.VarChar, 300);
                    command.Parameters["sp_lotstr"].Value = str_lot;
                    command.Parameters.Add("sp_memo", OracleType.VarChar, 255);
                    command.Parameters["sp_memo"].Value = ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim();
                    command.Parameters.Add("sp_rec_count", OracleType.Int32);
                    command.Parameters["sp_rec_count"].Value = i_rec_count;
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = str_userid;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 255);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        ls_middle = ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (ls_middle.Trim() != "")
            {
                dbCenter.Rollback();
            }
            else
            {
                dbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return ls_middle.Trim();
    }

    //PC机上的收货确认
    [WebMethod]
    public string oracle_confirm_asnno(string s_org, DataSet ds_asn, string str_userid)
    {
        string s_str, s_pallet_flag, s_pa_flag, s_sugg_loc, s_asntype, s_taxdist;
        string str_rec_no,s_type,ls_middle; //收货的次数 
        int i_rec_no;
        DataSet ds_sku;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        ls_middle = "";  
        try
        { 
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //得到是否上架计算的参数
            s_str = "select nvl(id_data,'0') from " + g_usespace + ".sys_parameter where inv_org = '" + s_org + "' and id = 8102";
            s_pa_flag = oracle_exec_selectstring(s_str);
            s_str = "select nvl(max(to_number(standby_5)),0) + 1 from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no = '" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
            str_rec_no = oracle_exec_selectstring(s_str);
            //得到单据类型
            s_str = "select asn_type from " + g_usespace + ".asn_order_header where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no = '" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
            s_type = oracle_exec_selectstring(s_str);
            //循环插入收货确认的数据
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                if (ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() != "0") //说明有收货数
                {
                    //得到最大行号
                    s_str = "select nvl(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '"+s_org+"' and consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' " +
                            "and asn_no ='" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "' and asn_line_no =" + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = s_str;
                    i_rec_no = dbCenter.ExecuteScalar(command);
                    i_rec_no = i_rec_no + 1;
                    //判断该商品是托盘管理还是非托盘管理
                    s_str = "select nvl(a.pallet_flag,'0') pallet_flag,b.asn_type,c.tax_dist from " + g_usespace + ".mst_sku a,"+g_usespace+".asn_order_header b,"+g_usespace+".asn_order_detail c where a.inv_org = '"+s_org+"' and a.consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + 
                           "' and a.sku = '" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and a.inv_org = c.inv_org and a.consignor = c.consignor and a.sku = c.sku and c.inv_org = b.inv_org and c.consignor = b.consignor and c.asn_no = b.asn_no";
                    ds_sku = oracle_exec_selectsql(s_str);
                    s_asntype = ds_sku.Tables[0].Rows[0]["asn_type"].ToString().Trim();
                    s_taxdist = ds_sku.Tables[0].Rows[0]["tax_dist"].ToString().Trim();
                    s_pallet_flag = ds_sku.Tables[0].Rows[0]["pallet_flag"].ToString().Trim();
                    //插入收货数据 
                    s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,    consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                                    "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                                    "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                    "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                    "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                            "values('"+s_org+"','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + "," +
                            System.Convert.ToString(i_rec_no) + ",'" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" +
                            ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + "," +
                            ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim() + "," +
                            ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" + DateTime.Now.ToString("yyyy.MM.dd") + "',";
                    if (s_pallet_flag == "0")  //非托盘管理，直接插入拆板，并且状态是拆板
                    {
                        s_str = s_str + "'1',";
                    }   
                    else  //托盘，不拆板，状态是收货确认 
                    {
                        s_str = s_str + "'0',";
                    }
                    s_str = s_str + "'" + ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                        ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                        ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                        ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "','','','','','" + str_rec_no + "',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',sysdate,'" + str_userid + "')";
                    command.CommandText = s_str;
                    dbCenter.ExecuteNonQuery(command);
                    //如果是非托盘，插入拆版数据
                    if (s_pallet_flag == "0")
                    {
                        s_str = "insert into " + g_usespace + ".asn_pallet_split(inv_org,       consignor,	asn_no,		asn_line_no,	receive_line_no,	pallet_no,	sku,		pack_code,	order_price,order_unit," +
                                                                "pallet_qty_m,	pallet_qty_s,	main_sub_flag,	convert_modulus,	shelflife_day, cubage,		gross_weight," +
                                                                "net_weight,	spliter,	split_status,	split_date,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                                "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                                "lot_attribute13,	lot_attribute14,	lot_attribute15,	standby_1,	standby_2,	standby_3,	standby_4,	standby_5," +
                                                                "standby_6,	standby_7,	memo,		main_dist,	made_time,	maker) " +
                                " values('" + s_org + "','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + "," +
                                System.Convert.ToString(i_rec_no) + ",'000000000000000','" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "'," +
                                System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim())) + "," +
                                System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim())) + ",'" +
                                ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + ",'" +
                                str_userid + "','0','" + DateTime.Now.ToString("yyyy.MM.dd") + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "','','','','','" + str_rec_no + "',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',sysdate,'" + str_userid + "')";
                        command.CommandText = s_str;
                        dbCenter.ExecuteNonQuery(command);

                        //如果是非托盘管理并且不需要上架计算,直接插入上架计算表
                        //2012.05.25针对鑫马非托盘管理,收货后是否直接插入上架计算表
                        if (s_pa_flag == "1") //直接插入上架计算表
                        {
                            //得到相应商品的有库存的库位
                            //s_asntype, s_taxdist;location_flag
                            s_str = "select nvl(max(a.location_code),'') from " + g_usespace + ".inv_sku_location a," + g_usespace + ".mst_location b where a.inv_org = '" + s_org + "' and a.consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and a.sku = '" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and a.pack_code = '" +
                                    ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "' and a.inv_org = b.inv_org and a.location_code = b.location_code and b.lock_flag = '0'";
                            if (s_asntype == "3") //寄售
                            {
                                s_str = s_str + " and b.location_flag = '3'";
                            }
                            else
                            {
                                s_str = s_str + " and b.location_flag = '0'";
                            }
                            if (s_taxdist.Trim() == "保税") //保税区分
                            {
                                s_str = s_str + " and b.standby_flag1 = '1'";
                            }
                            else
                            {
                                s_str = s_str + " and b.standby_flag1 = '0'";
                            }
                            s_sugg_loc = oracle_exec_selectstring(s_str);
                            s_str = "insert into " + g_usespace + ".asn_putaway(inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                               "receive_line_no,	pallet_no,	sku,		pack_code," +
                                                                               "order_price,	order_unit,	putaway_qty_m,	putaway_qty_s," +
                                                                               "main_sub_flag,	convert_modulus,	suggest_location,	shelflife_day," +
                                                                               "cubage,		gross_weight,	net_weight,	putaway_status," +
                                                                               "fact_location,	putawayer,	putaway_flag,	putaway_date," +
                                                                               "print_flag,	printer,	label_flag," +
                                                                               "labeler,	lot_attribute1,	lot_attribute2," +
                                                                               "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                               "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                               "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                               "lot_attribute15,	standby_1,	standby_2,	standby_3," +
                                                                               "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                               "memo,		main_dist,	made_time,	maker) " +
                                    " values('" + s_org + "','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + "," +
                                    System.Convert.ToString(i_rec_no) + ",'000000000000000','" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "'," +
                                    System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim())) + "," +
                                    System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim())) + ",'" +
                                    ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" + s_sugg_loc + "'," + ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + "," +
                                    "'0','','','1','','0','','0','','" + ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                                ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                                ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                                ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "','','','','','" + str_rec_no + "',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',sysdate,'" + str_userid + "')";
                            command.CommandText = s_str;
                            dbCenter.ExecuteNonQuery(command);
                        }

                        if (s_pa_flag == "2") //调用上架计算存储过程
                        {
                            if (s_pallet_flag == "0") // 只有非托盘的才能调用
                            {
                                command.CommandType = CommandType.StoredProcedure;
                                command.CommandText = g_usespace + ".SP_ORACLE_PUTAWAY";
                                command.Parameters.Add("sp_org", OracleType.Char, 15);
                                command.Parameters["sp_org"].Value = s_org;
                                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                                command.Parameters["sp_csgor"].Value = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                                command.Parameters.Add("sp_asn", OracleType.Char, 20);
                                command.Parameters["sp_asn"].Value = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                                command.Parameters.Add("sp_lineno", OracleType.Int32);
                                command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                                command.Parameters.Add("sp_recno", OracleType.Int32);
                                command.Parameters["sp_recno"].Value = i_rec_no;
                                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                                command.Parameters["sp_pallet"].Value = "000000000000000";
                                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim());
                                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                                command.Parameters["sp_sku"].Value = ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim();
                                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                                command.Parameters["sp_pack"].Value = ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                                command.Parameters.Add("sp_user", OracleType.Char, 10);
                                command.Parameters["sp_user"].Value = str_userid;
                                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                                command.Parameters["sp_loc"].Direction = ParameterDirection.Output;
                                dbCenter.ExecuteNonQuery(command);
                                if (command.Parameters["sp_loc"].Value.ToString().Trim().Substring(0, 3).ToUpper() == "ERR")
                                {
                                    ls_middle = ls_middle + command.Parameters["sp_loc"].Value.ToString().Trim();
                                }
                                command.Parameters.Clear();
                                command.CommandType = CommandType.Text;
                                if (ls_middle.Trim() != "")
                                {
                                    break;
                                }
                            }
                        }
                    }
                    
                    //修改订单明细的状态
                    s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = nvl(receive_qty_m,0) + " + ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() + "," +
                                                                       "receive_qty_s = nvl(receive_qty_s,0) + " + ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim() + "," +
                                                                       "receive_present_qty_m = nvl(receive_present_qty_m,0) + " + ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim() + "," +
                                                                       "receive_present_qty_s = nvl(receive_present_qty_s,0) + " + ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim() + "," +
                                                                       "receive_day = case trim(nvl(receive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                                       "receive_status = case when nvl(receive_qty_m,0) +" + ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() + " >= nvl(order_qty_m,0) then '2' else '1' end," +
                                                                       "main_dist = 'C',update_time = sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and " +
                                                                       "asn_no='" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "' and asn_line_no =" + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = s_str;
                    dbCenter.ExecuteNonQuery(command);
                    if (s_type.Trim() == "8" || s_type.Trim() == "9" || s_type.Trim() == "4")  //说明是委外或者外协,调用存储过程
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.CommandText = g_usespace + ".SP_ORL_RECEIVE_DELEGATE";
                        command.Parameters.Add("sp_org", OracleType.Char, 15);
                        command.Parameters["sp_org"].Value = s_org;
                        command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                        command.Parameters["sp_csgor"].Value = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                        command.Parameters.Add("sp_asn", OracleType.Char, 20);
                        command.Parameters["sp_asn"].Value = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                        command.Parameters.Add("sp_lineno", OracleType.Int32);
                        command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                        command.Parameters.Add("sp_sku", OracleType.Char, 30);
                        command.Parameters["sp_sku"].Value = ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim();
                        command.Parameters.Add("sp_pack", OracleType.Char, 30);
                        command.Parameters["sp_pack"].Value = ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                        command.Parameters.Add("sp_qtym", OracleType.Number, 16);
                        command.Parameters["sp_qtym"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim());
                        command.Parameters.Add("sp_lot6", OracleType.Char, 20);
                        command.Parameters["sp_lot6"].Value = ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim();
                        command.Parameters.Add("sp_type", OracleType.Char, 1);
                        command.Parameters["sp_type"].Value = s_type;
                        command.Parameters.Add("sp_user", OracleType.Char, 10);
                        command.Parameters["sp_user"].Value = str_userid;
                        command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                        command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                        dbCenter.ExecuteNonQuery(command);
                        if (command.Parameters["sp_out"].Value.ToString().Trim() != "1")
                        {
                            ls_middle = ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        }
                        command.Parameters.Clear();
                        command.CommandType = CommandType.Text;
                        if (ls_middle.Trim() != "")
                        {
                            break;
                        } 
                    }
                    //插入库存交易明细
                    s_str = "insert into " + g_usespace + ".Inv_Transaction(inv_org,  transaction_id,  happen_time,  transaction_type," +
                                                                      "bill_type,  bill_no,  bill_line_no,  batchno," +
                                                                      "location_code,  pallet_no,  consignor,  sku," +
                                                                      "order_price,  order_unit,  new_batchno,  new_location_code," +
                                                                      "new_pallet_no,  new_consignor,  new_sku,  new_order_price," +
                                                                      "new_order_unit,  pack_code,  main_sub_flag,  convert_modulus," +
                                                                      "shelflife_day,  stock_qty_m,  stock_qty_s,  cubage," +
                                                                      "gross_weight,  net_weight,  new_cubage,  new_gross_weight," +
                                                                      "new_net_weight,  happen_qty_m,  happen_qty_s,  renson_code," +
                                                                      "lot_attribute1,  lot_attribute2,  lot_attribute3,  lot_attribute4," +
                                                                      "lot_attribute5,  lot_attribute6,  lot_attribute7,  lot_attribute8," +
                                                                      "lot_attribute9,  lot_attribute10,  lot_attribute11,  lot_attribute12," +
                                                                      "lot_attribute13,  lot_attribute14,  lot_attribute15,  standby_1," +
                                                                      "standby_2,  standby_3,  standby_4,  standby_5," +
                                                                      "standby_6,  standby_7,  memo,    main_dist," +
                                                                      "made_time,  maker)" +
                                              " values('" + s_org + "',trans_id.nextval,sysdate,'PR','" +
                                               s_type.Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + ",'0'," +
                                               "'0','000000000000000','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "'," +
                                               ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "','',''," +
                                               "'','','',0," +
                                               "'','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + "," +
                                               ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + ",0,0," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," +
                                               ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + ",0,0," +
                                               "0," + System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim())) + "," + System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim())) + ",'','" +
                                               ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                                               ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                                               ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                                               ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "',''," +
                                               "'','','','',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',sysdate,'" + str_userid + "')";
                    command.CommandType = CommandType.Text;
                    command.CommandText = s_str;
                    dbCenter.ExecuteNonQuery(command);
                } 
            }
            if (ls_middle.Trim() == "")
            {
                //全部更新完成后修改表头的状态
                s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no ='" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "' and receive_status in ('0','1')";
                command.CommandText = s_str;
                i_rec_no = dbCenter.ExecuteScalar(command);
                s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case trim(nvl(arrive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
                if (i_rec_no > 0)//说明还没有收完
                    s_str = s_str + "arrive_status = '1',";
                else
                    s_str = s_str + "arrive_status = '2',";
                s_str = s_str + "main_dist = 'C',update_time=sysdate,updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no ='" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            if (ls_middle.Trim() != "")
            {
                dbCenter.Rollback();
            }
            else
            {
                dbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return ls_middle.Trim();
    }

    //portal收货确认,拆板,上架计算(目前只针对托盘管理的商品
    [WebMethod]
    public void oracle_confirm_protalasn(string s_org, DataSet ds_asn, string str_userid,string str_day)
    {
        string s_str,str_precon,str_con,str_asn,str_preasn;
        int i_line,i_pre_line,i_max_recno;
        decimal d_1, d_2;
        decimal d_ls;
        str_precon = "";
        str_preasn = "";
        i_pre_line = 0;
        d_1 = 0;
        d_2 = 0;
        i_max_recno = 0; 
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //循环插入收货确认的数据
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                if (i == 0)
                {
                    str_precon = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    str_preasn = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    i_pre_line = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    d_1 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()),4);
                    d_2 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                    //得到最大行号
                    s_str = "select nvl(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' " +
                            "and asn_no ='" + str_preasn + "' and asn_line_no =" + System.Convert.ToString(i_pre_line);
                    command.CommandText = s_str;
                    i_max_recno = dbCenter.ExecuteScalar(command);
                    i_max_recno = i_max_recno + 1;
                }
                str_con = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_asn = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                i_line = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                if (str_con != str_precon || str_asn != str_preasn || i_line != i_pre_line) //说明换了收货明细,修改相应的数据
                {
                    //插入前一条收货明细 
                    d_ls = d_1 + d_2;
                    s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,   consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                                    "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                                    "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                    "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                    "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                            " select inv_org,consignor,asn_no,asn_line_no," + System.Convert.ToString(i_max_recno) + ",sku,pack_code,order_price,order_unit," +
                            "Round(" + System.Convert.ToString(d_ls) + " * nvl(cubage,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * nvl(gross_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4)," +
                            "Round(" + System.Convert.ToString(d_ls) + " * nvl(net_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),shelflife_day,"+System.Convert.ToString(d_1)+",Round(" + System.Convert.ToString(d_1) + " * nvl(convert_modulus,1),4),"+
                            System.Convert.ToString(d_2) + ",Round(" + System.Convert.ToString(d_2) + " * nvl(convert_modulus,1),4),main_sub_flag,	convert_modulus,to_char(sysdate,'YYYY.MM.DD'),'1','" + str_day + "',to_char(sysdate,'YYYY.MM.DD'),'','','','','','','',''," +
                            "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',sysdate,'"+str_userid+"'"+
                            " from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and asn_no = '" + str_preasn + "' and asn_line_no = " + System.Convert.ToString(i_pre_line);
                    command.CommandText = s_str;
                    dbCenter.ExecuteNonQuery(command);
                    //更新前一条收货数据
                    //修改订单明细的状态
                    s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = nvl(receive_qty_m,0) + " + System.Convert.ToString(d_1) + "," +
                                                                       "receive_qty_s = nvl(receive_qty_s,0) + Round(" + System.Convert.ToString(d_1) + " * nvl(convert_modulus,1),4),"+
                                                                       "receive_present_qty_m = nvl(receive_present_qty_m,0) + " + System.Convert.ToString(d_2) + "," +
                                                                       "receive_present_qty_s = nvl(receive_present_qty_s,0) + Round(" + System.Convert.ToString(d_2) + " * nvl(convert_modulus,1),4)," +
                                                                       "receive_day = case trim(nvl(receive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                                       "receive_status = case when nvl(receive_qty_m,0) +" + System.Convert.ToString(d_1) + " >= nvl(order_qty_m,0) then '2' else '1' end," +
                                                                       "main_dist = 'C',update_time = sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and " +
                                                                       "asn_no='" + str_preasn + "' and asn_line_no =" + System.Convert.ToString(i_pre_line);
                    command.CommandText = s_str;
                    dbCenter.ExecuteNonQuery(command);
                    //得到新的收货信息
                    d_1 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()), 4);
                    d_2 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                    //得到最大行号
                    s_str = "select nvl(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' " +
                            "and asn_no ='" + str_asn + "' and asn_line_no =" + System.Convert.ToString(i_line);
                    command.CommandText = s_str;
                    i_max_recno = dbCenter.ExecuteScalar(command);
                    i_max_recno = i_max_recno + 1;
                    str_precon = str_con;
                    str_preasn = str_asn;
                    i_pre_line = i_line;
                }
                else
                {
                    if (i != 0)  //说明不是第一条要累加
                    {
                        d_1 = d_1 + Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()), 4);
                        d_2 = d_2 + Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                    }
                }
                //插入拆板的数据
                d_ls = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()),4);
                s_str = "insert into " + g_usespace + ".asn_pallet_split(inv_org,consignor,asn_no,asn_line_no,receive_line_no,pallet_no,sku,pack_code,order_price,order_unit," +
                                                                "pallet_qty_m,pallet_qty_s,main_sub_flag,convert_modulus,shelflife_day, cubage,gross_weight," +
                                                                "net_weight,spliter,split_status,split_date,lot_attribute1,lot_attribute2,lot_attribute3,lot_attribute4," +
                                                                "lot_attribute5,lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,lot_attribute10,lot_attribute11,lot_attribute12," +
                                                                "lot_attribute13,lot_attribute14,lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5," +
                                                                "standby_6,standby_7,memo,main_dist,made_time,maker)" +
                        " select inv_org,consignor,asn_no,asn_line_no," + System.Convert.ToString(i_max_recno) + ",'" + ds_asn.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "',sku,pack_code,order_price,order_unit," +
                        System.Convert.ToString(d_ls) + ",Round(" + System.Convert.ToString(d_ls) + " * nvl(convert_modulus,1),4),main_sub_flag,	convert_modulus,shelflife_day," +
                        "Round(" + System.Convert.ToString(d_ls) + " * nvl(cubage,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * nvl(gross_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4)," +
                        "Round(" + System.Convert.ToString(d_ls) + " * nvl(net_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),'" + str_userid + "','0',to_char(sysdate,'YYYY.MM.DD'),'" + str_day + "',to_char(sysdate,'YYYY.MM.DD'),'','','','','','','',''," +
                        "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',sysdate,'" + str_userid + "'" +
                        " from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line);
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            } 
            //出来之后,插入收货明细和更新收货明细
            //插入前一条收货明细 
            d_ls = d_1 + d_2;
            s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,consignor,asn_no,asn_line_no,receive_line_no,sku,pack_code,order_price,order_unit," +
                                            "cubage,gross_weight,net_weight,shelflife_day,receive_qty_m,receive_qty_s,receive_present_qty_m,receive_present_qty_s," +
                                            "main_sub_flag,convert_modulus,receive_day,fact_status,lot_attribute1,lot_attribute2,lot_attribute3,lot_attribute4," +
                                            "lot_attribute5,lot_attribute6,lot_attribute7,lot_attribute8,lot_attribute9,lot_attribute10,lot_attribute11,lot_attribute12," +
                                            "lot_attribute13,lot_attribute14,lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                    " select inv_org,consignor,asn_no,asn_line_no," + System.Convert.ToString(i_max_recno) + ",sku,pack_code,order_price,order_unit," +
                    "Round(" + System.Convert.ToString(d_ls) + " * nvl(cubage,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * nvl(gross_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4)," +
                    "Round(" + System.Convert.ToString(d_ls) + " * nvl(net_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),shelflife_day," + System.Convert.ToString(d_1) + ",Round(" + System.Convert.ToString(d_1) + " * nvl(convert_modulus,1),4)," +
                    System.Convert.ToString(d_2) + ",Round(" + System.Convert.ToString(d_2) + " * nvl(convert_modulus,1),4),main_sub_flag,	convert_modulus,to_char(sysdate,'YYYY.MM.DD'),'1','" + str_day + "',to_char(sysdate,'YYYY.MM.DD'),'','','','','','','',''," +
                    "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',sysdate,'" + str_userid + "'" +
                    " from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and asn_no = '" + str_preasn + "' and asn_line_no = " + System.Convert.ToString(i_pre_line);
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //更新前一条收货数据
            //修改订单明细的状态
            s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = nvl(receive_qty_m,0) + " + System.Convert.ToString(d_1) + "," +
                                                               "receive_qty_s = nvl(receive_qty_s,0) + Round(" + System.Convert.ToString(d_1) + " * nvl(convert_modulus,1),4)," +
                                                               "receive_present_qty_m = nvl(receive_present_qty_m,0) + " + System.Convert.ToString(d_2) + "," +
                                                               "receive_present_qty_s = nvl(receive_present_qty_s,0) + Round(" + System.Convert.ToString(d_2) + " * nvl(convert_modulus,1),4)," +
                                                               "receive_day = case trim(nvl(receive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                               "receive_status = case when nvl(receive_qty_m,0) +" + System.Convert.ToString(d_1) + " >= nvl(order_qty_m,0) then '2' else '1' end," +
                                                               "main_dist = 'C',update_time = sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and " +
                                                               "asn_no='" + str_preasn + "' and asn_line_no =" + System.Convert.ToString(i_pre_line);
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command); 
            //出来之后修改整个订单的状态,并且进行相应的上架计算
            int i_rec_no; 
            str_precon = ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim();
            str_preasn = ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim();
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                str_con = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_asn = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                if (str_con != str_precon || str_asn != str_preasn)  //说明变化了,更新前一个
                {
                    //全部更新完成后修改表头的状态
                    s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "' and receive_status in ('0','1')";
                    command.CommandText = s_str;
                    i_rec_no = dbCenter.ExecuteScalar(command);
                    s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case trim(nvl(arrive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
                    if (i_rec_no > 0)//说明还没有收完
                        s_str = s_str + "arrive_status = '1',";
                    else
                        s_str = s_str + "arrive_status = '2',";
                    s_str = s_str + "main_dist = 'C',update_time=sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "'";
                    command.CommandText = s_str;
                    dbCenter.ExecuteNonQuery(command);
                    //按订单调用上架计算的存储过程
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_PUTAWAY_LIST";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = s_org;
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = str_precon;
                    command.Parameters.Add("sp_asnno", OracleType.Char, 20);
                    command.Parameters["sp_asnno"].Value = str_preasn;
                    command.Parameters.Add("sp_asnline", OracleType.Int32);
                    command.Parameters["sp_asnline"].Value = 0;
                    command.Parameters.Add("sp_recline", OracleType.Int32);
                    command.Parameters["sp_recline"].Value = 0;
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = "temp";
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = str_userid;
                    dbCenter.ExecuteNonQuery(command);
                    command.Parameters.Clear();
                    command.CommandType = CommandType.Text;
                    str_precon = str_con;
                    str_preasn = str_asn;
                }
            } 
            //出来在更新一次
            //全部更新完成后修改表头的状态
            s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "' and receive_status in ('0','1')";
            command.CommandText = s_str;
            i_rec_no = dbCenter.ExecuteScalar(command);
            s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case trim(nvl(arrive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
            if (i_rec_no > 0)//说明还没有收完
                s_str = s_str + "arrive_status = '1',";
            else
                s_str = s_str + "arrive_status = '2',";
            s_str = s_str + "main_dist = 'C',update_time=sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //按订单调用上架计算的存储过程
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_ORL_PUTAWAY_LIST";
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = str_precon;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = str_preasn;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = 0;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = 0;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = "temp";
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = str_userid;
            dbCenter.ExecuteNonQuery(command);
            command.Parameters.Clear();
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //portal收货确认,拆板,上架计算(箱级管理)
    //ds_asn 一拖盘的收货  ,ds_box箱标
    [WebMethod]
    public void oracle_confirm_protalasnbox(string s_org, DataSet ds_asn, DataSet ds_box, string str_userid, string str_day)
    {
        string s_str, str_con, str_asn, str_select;
        int i_line, i_max_recno, i_rec_no;
        decimal d_1, d_2;
        decimal d_ls;
        d_1 = 0;
        d_2 = 0;
        i_max_recno = 0;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction(); 
            //插入收货确认的数据
            str_con = ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim();
            str_asn = ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim();
            i_line = System.Convert.ToInt32(ds_asn.Tables[0].Rows[0]["asn_line_no"].ToString().Trim());
            d_1 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[0]["quantity"].ToString().Trim()), 4);
            d_2 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[0]["present_quantity"].ToString().Trim()), 4);
            //得到最大行号
            s_str = "select nvl(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' " +
                    "and asn_no ='" + str_asn + "' and asn_line_no =" + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            i_max_recno = dbCenter.ExecuteScalar(command);
            i_max_recno = i_max_recno + 1;
            //插入前一条收货明细 
            d_ls = d_1 + d_2;
            s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                            "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                            "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                            "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                            "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                    " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",sku,		pack_code,	order_price,	order_unit," +
                    "Round(" + System.Convert.ToString(d_ls) + " * nvl(cubage,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * nvl(gross_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4)," +
                    "Round(" + System.Convert.ToString(d_ls) + " * nvl(net_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),shelflife_day," + System.Convert.ToString(d_1) + ",Round(" + System.Convert.ToString(d_1) + " * nvl(convert_modulus,1),4)," +
                    System.Convert.ToString(d_2) + ",Round(" + System.Convert.ToString(d_2) + " * nvl(convert_modulus,1),4),main_sub_flag,	convert_modulus,to_char(sysdate,'YYYY.MM.DD'),'1','" + str_day + "',to_char(sysdate,'YYYY.MM.DD'),'','','','','','','',''," +
                    "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',sysdate,'" + str_userid + "'" +
                    " from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //修改订单明细的状态
            s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = nvl(receive_qty_m,0) + " + System.Convert.ToString(d_1) + "," +
                                                               "receive_qty_s = nvl(receive_qty_s,0) + Round(" + System.Convert.ToString(d_1) + " * nvl(convert_modulus,1),4)," +
                                                               "receive_present_qty_m = nvl(receive_present_qty_m,0) + " + System.Convert.ToString(d_2) + "," +
                                                               "receive_present_qty_s = nvl(receive_present_qty_s,0) + Round(" + System.Convert.ToString(d_2) + " * nvl(convert_modulus,1),4)," +
                                                               "receive_day = case trim(nvl(receive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                               "receive_status = case when nvl(receive_qty_m,0) +" + System.Convert.ToString(d_1) + " >= nvl(order_qty_m,0) then '2' else '1' end," +
                                                               "main_dist = 'C',update_time = sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + str_con + "' and " +
                                                               "asn_no='" + str_asn + "' and asn_line_no =" + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //插入拆板的数据
            s_str = "insert into " + g_usespace + ".asn_pallet_split(inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,	pallet_no,	sku,		pack_code,	order_price,order_unit," +
                                                            "pallet_qty_m,	pallet_qty_s,	main_sub_flag,	convert_modulus,	shelflife_day, cubage,		gross_weight," +
                                                            "net_weight,	spliter,	split_status,	split_date,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                            "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                            "lot_attribute13,	lot_attribute14,	lot_attribute15,	standby_1,	standby_2,	standby_3,	standby_4,	standby_5," +
                                                            "standby_6,	standby_7,	memo,		main_dist,	made_time,	maker)" +
                    " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",'" + ds_asn.Tables[0].Rows[0]["pallet_no"].ToString().Trim() + "',sku,pack_code,order_price,order_unit," +
                    System.Convert.ToString(d_ls) + ",Round(" + System.Convert.ToString(d_ls) + " * nvl(convert_modulus,1),4),main_sub_flag,	convert_modulus,shelflife_day," +
                    "Round(" + System.Convert.ToString(d_ls) + " * nvl(cubage,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * nvl(gross_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4)," +
                    "Round(" + System.Convert.ToString(d_ls) + " * nvl(net_weight,0) / (nvl(order_qty_m,0) + nvl(present_qty_m,0)),4),'" + str_userid + "','0',to_char(sysdate,'YYYY.MM.DD'),'" + str_day + "',to_char(sysdate,'YYYY.MM.DD'),'','','','','','','',''," +
                    "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',sysdate,'" + str_userid + "'" +
                    " from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //更细托盘号到箱级标签
            str_select = "";
            for (int i = 0; i < ds_box.Tables[0].Rows.Count; i++)
            {
                str_select = str_select + "'" + ds_box.Tables[0].Rows[i]["box_rfid"].ToString().Trim() + "',";
            }
            str_select = str_select.Substring(0, str_select.Length - 1);
            s_str = "update " + g_usespace + ".asn_order_rfid set pallet_no = '" + ds_asn.Tables[0].Rows[0]["pallet_no"].ToString().Trim() + "',status = '1' where inv_org = '"+s_org+"' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line) +
                    " and box_rfid in (" + str_select + ") and status = '0'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //全部更新完成后修改表头的状态
            s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' and asn_no ='" + str_asn + "' and receive_status in ('0','1')";
            command.CommandText = s_str;
            i_rec_no = dbCenter.ExecuteScalar(command);
            s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case trim(nvl(arrive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
            if (i_rec_no > 0)//说明还没有收完
                s_str = s_str + "arrive_status = '1',";
            else
                s_str = s_str + "arrive_status = '2',";
            s_str = s_str + "main_dist = 'C',update_time=sysdate,updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no ='" + str_asn + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            //按订单调用上架计算的存储过程
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_ORL_PUTAWAY_LIST";
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = str_con;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = str_asn;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = 0;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = 0;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = "temp";
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = str_userid;
            dbCenter.ExecuteNonQuery(command);
            command.Parameters.Clear();
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //正大富通版修改托盘号和数量
    [WebMethod]
    public void oracle_modify_pallet_new(string s_org, DataSet dtst, string strsql,string s_user)
    {
        string str_update_sql;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, dtst);
            //然后循环修改inv_sku_pallet里面的数据
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    str_update_sql = "update " + g_usespace + ".inv_sku_pallet set pallet_no = '" + dtst.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "',stock_qty_m = nvl(stock_qty_m,0) - " + dtst.Tables[0].Rows[i]["old_pallet_m"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["pallet_qty_m"].ToString().Trim() +
                        ",stock_qty_s = nvl(stock_qty_s,0) - " + dtst.Tables[0].Rows[i]["old_pallet_s"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["pallet_qty_s"].ToString().Trim() + ",cubage = nvl(cubage,0) - " + dtst.Tables[0].Rows[i]["old_cubage"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["cubage"].ToString().Trim() +
                        ",gross_weight = nvl(gross_weight,0) - " + dtst.Tables[0].Rows[i]["old_gross_weight"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["gross_weight"].ToString().Trim() + ",net_weight = nvl(net_weight,0) - " + dtst.Tables[0].Rows[i]["old_net_weight"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["net_weight"].ToString().Trim() +
                        ",update_time = sysdate,updater = '" + s_user.Trim() + "' where inv_org = '" + s_org.Trim() + "' and batchno = '" + dtst.Tables[0].Rows[i]["batchno"].ToString().Trim() + "' and location_code = 'STAGE' and pallet_no = '" + dtst.Tables[0].Rows[i]["old_pallet"].ToString().Trim() + "'";
                    command.CommandType = CommandType.Text;
                    command.CommandText = str_update_sql;
                    dbCenter.ExecuteNonQuery(command);
                }
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //上架计算存储过程
    [WebMethod]
    public void oracle_exec_proc_putaway(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PUTAWAY_LIST");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command); 
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        { 
            dbCenter.CloseConnection();
        }
    }

    //新上架计算存储过程
    [WebMethod]
    public string oracle_exec_proc_putaway_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PUTAWAY_LIST_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //判断输入的上架库位是否有效 
    [WebMethod]
    public string oracle_exec_proc_judgeloc(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_loc)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_JUDGE_LOC");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asn", OracleType.Char, 20);
            command.Parameters["sp_asn"].Value = s_asn_no;
            command.Parameters.Add("sp_lineno", OracleType.Int32);
            command.Parameters["sp_lineno"].Value = i_asnno;
            command.Parameters.Add("sp_recno", OracleType.Int32);
            command.Parameters["sp_recno"].Value = i_recno;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }


    //正大富通版判断输入的上架库位是否有效 
    [WebMethod]
    public string oracle_exec_proc_judgeloc_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, int i_putaway, string s_pallet, string s_loc)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_JUDGE_LOC_NEW");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asn", OracleType.Char, 20);
            command.Parameters["sp_asn"].Value = s_asn_no;
            command.Parameters.Add("sp_lineno", OracleType.Int32);
            command.Parameters["sp_lineno"].Value = i_asnno;
            command.Parameters.Add("sp_recno", OracleType.Int32);
            command.Parameters["sp_recno"].Value = i_recno;
            command.Parameters.Add("sp_putawayno", OracleType.Int32);
            command.Parameters["sp_putawayno"].Value = i_putaway;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //修改实际上架库位，并且直接上架确认
    [WebMethod]
    public string oracle_exec_proc_pasaveandcon(string s_org, DataSet ds_save, string s_sql, string s_method, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = s_sql;
            dbCenter.updatedatabaser(command, ds_save);
            for (int i = 0; i < ds_save.Tables[0].Rows.Count; i++) //有实际库位并且没有确认的进行确认
            {
                if (ds_save.Tables[0].Rows[i]["putaway_status"].ToString().Trim() == "0" && ds_save.Tables[0].Rows[i]["fact_location"].ToString().Trim() != "") //说明需要确认
                {
                    command.CommandText = g_usespace + ".SP_ORL_PA_CONFIRM"; 
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = s_org;
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_save.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_save.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_recno", OracleType.Int32);
                    command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = ds_save.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_method", OracleType.Char, 1);
                    command.Parameters["sp_method"].Value = s_method;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 50);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //新修改实际上架库位，并且直接上架确认
    [WebMethod]
    public string oracle_exec_proc_pasaveandcon_new(string s_org, DataSet ds_save, string s_sql, string s_method, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction(); 
            command.CommandText = s_sql;
            dbCenter.updatedatabaser(command, ds_save);
            for (int i = 0; i < ds_save.Tables[0].Rows.Count; i++) //有实际库位并且没有确认的进行确认
            {
                if (ds_save.Tables[0].Rows[i]["putaway_status"].ToString().Trim() == "0" && ds_save.Tables[0].Rows[i]["fact_location"].ToString().Trim() != "") //说明需要确认
                {
                    if (System.Convert.ToDecimal(ds_save.Tables[0].Rows[i]["pa_qty_m"].ToString().Trim()) <= 0)
                    {
                        ds_save.Tables[0].Rows[i]["pa_qty_m"] = Math.Round(System.Convert.ToDecimal(ds_save.Tables[0].Rows[i]["putaway_qty_m"].ToString().Trim()), 4);
                    }
                    command.CommandText = g_usespace + ".SP_ORL_PA_CONFIRM_NEW";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = s_org;
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_save.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_save.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_recno", OracleType.Int32);
                    command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = ds_save.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("sp_putawayno", OracleType.Int32);
                    command.Parameters["sp_putawayno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["putaway_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_pa_qtym", OracleType.Number, 16);
                    command.Parameters["sp_pa_qtym"].Value = System.Convert.ToDecimal(ds_save.Tables[0].Rows[i]["pa_qty_m"].ToString().Trim());
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_method", OracleType.Char, 1);
                    command.Parameters["sp_method"].Value = s_method;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 255);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //上架确认存储过程
    [WebMethod]
    public string oracle_exec_proc_pacon(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_method, string s_user, string str_fact_loc)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PA_CON_LIST");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20); 
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_method", OracleType.Char, 1);
            command.Parameters["sp_method"].Value = s_method;
            command.Parameters.Add("sp_fact_loc", OracleType.Char, 20);
            command.Parameters["sp_fact_loc"].Value = str_fact_loc;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //新上架确认存储过程
    [WebMethod]
    public string oracle_exec_proc_pacon_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_method, string s_user, string str_fact_loc)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PA_CON_LIST_NEW");
        DatabaseController dbCenter = new DatabaseController();
        try
        { 
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asnno", OracleType.Char, 20);
            command.Parameters["sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("sp_asnline", OracleType.Int32);
            command.Parameters["sp_asnline"].Value = i_asnno;
            command.Parameters.Add("sp_recline", OracleType.Int32);
            command.Parameters["sp_recline"].Value = i_recno;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_method", OracleType.Char, 1);
            command.Parameters["sp_method"].Value = s_method;
            command.Parameters.Add("sp_fact_loc", OracleType.Char, 20);
            command.Parameters["sp_fact_loc"].Value = str_fact_loc;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //上架取消
    [WebMethod]
    public string oracle_exec_proc_pacancel(DataSet ds_pacancel, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_pacancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_pacancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_PA_CANCEL";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_pacancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_pacancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_pacancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_recno", OracleType.Int32);
                    command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = ds_pacancel.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_memo", OracleType.VarChar, 100);
                    command.Parameters["sp_memo"].Value = ds_pacancel.Tables[0].Rows[i]["reason"].ToString().Trim();
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit(); 
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //新上架取消
    [WebMethod]
    public string oracle_exec_proc_pacancel_new(DataSet ds_pacancel, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_pacancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_pacancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_PA_CANCEL_NEW";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_pacancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_pacancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_pacancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_recno", OracleType.Int32);
                    command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = ds_pacancel.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("sp_putawayno", OracleType.Int32);
                    command.Parameters["sp_putawayno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["putaway_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_memo", OracleType.VarChar, 100);
                    command.Parameters["sp_memo"].Value = ds_pacancel.Tables[0].Rows[i]["reason"].ToString().Trim();
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //收货取消
    [WebMethod]
    public string oracle_exec_proc_receive_cancel(DataSet ds_receive_cancel, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_receive_cancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_receive_cancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_RECEIVE_CANCEL";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_receive_cancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_receive_cancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_receive_cancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_recno", OracleType.Int32);
                    command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //新收货取消
    [WebMethod]
    public string oracle_exec_proc_receive_cancel_new(DataSet ds_receive_cancel, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_receive_cancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_receive_cancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_RECEIVE_CANCEL_NEW";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_receive_cancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_receive_cancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_asn", OracleType.Char, 20);
                    command.Parameters["sp_asn"].Value = ds_receive_cancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("sp_lineno", OracleType.Int32);
                    command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_recno", OracleType.Int32);
                    command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 255);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    #endregion

    #region 出库单管理的函数
    //删除整张出库单信息，存在表头和明细，所以要在一个事物里面删除
    [WebMethod]
    public void oracle_del_sono(string s_org, string str_sto, string str_soh)
    {
        string s_str;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //判断是否存在波次中
            s_str = "select wave_flag from " + g_usespace + ".so_ship_header where inv_org = '"+s_org+"' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
            s_str = oracle_exec_selectstring(s_str);
            if (s_str == "1") //说明存在波次中，需要删除
            {
                s_str = "delete " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            //删除明细
            s_str = "delete " + g_usespace + ".so_ship_detail where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command); 
            //在删除表头
            s_str = "delete " + g_usespace + ".so_ship_header where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //拆分出库单
    [WebMethod]
    public void oracle_exec_proc_shipbom(string s_org, string s_consignor, string s_so_no, string s_sku, decimal d_shipm, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_SPLIT_SHIP");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_so_no", OracleType.Char, 20);
            command.Parameters["sp_so_no"].Value = s_so_no;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_shipm", OracleType.Number, 16);
            command.Parameters["sp_shipm"].Value = d_shipm;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //波次做成
    [WebMethod]
    public void oracle_exec_makewave(string s_org, DataSet ds_tmp, string s_user, string str_flag)
    {
        //str_flag  0则是新添加的  1则是追加的不需要表头
        string s_str;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (str_flag == "0")
            {
                //首先插入波次号
                s_str = "insert into " + g_usespace + ".so_ship_wave (inv_org,consignor,	wave_no,	wave_description,	wave_day," +
                                                                   "confirm_day,	confirmer,	wave_status,	standby_1," +
                                                                   "standby_2,	standby_3,	standby_4,	standby_5," +
                                                                   "memo,		main_dist,	made_time,	maker)" +
                                                   " values ('"+s_org+"','" + ds_tmp.Tables[0].Rows[0]["consignor"].ToString().Trim() + "','" + ds_tmp.Tables[0].Rows[0]["wave_no"].ToString().Trim() + "','',to_char(sysdate,'YYYY.MM.DD')," +
                                                   "'','','0','','','',0," + ds_tmp.Tables[0].Rows[0]["attribute"].ToString().Trim() + ",'','A',sysdate,'" + s_user + "')";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            //循环插入明细
            for (int i = 0; i < ds_tmp.Tables[0].Rows.Count; i++)
            {
                s_str = "insert into " + g_usespace + ".so_ship_wavedetail (inv_org,consignor,	wave_no,	so_no,		standby_1," +
                                                                            "standby_2,	standby_3,	memo,		main_dist," +
                                                                            "made_time,	maker)" +
                                               " values ('"+s_org+"','" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_tmp.Tables[0].Rows[i]["wave_no"].ToString().Trim() + "','" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'," +
                                               "'','',0,'','A',sysdate,'" + s_user + "')";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
                //更改出库单为波次做成
                s_str = "update " + g_usespace + ".so_ship_header set wave_flag = '1',main_dist='C',update_time=sysdate,updater='" + s_user + "' where inv_org = '"+s_org+"' and consignor='" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and so_no ='" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //波次删除
    [WebMethod]
    public void oracle_exec_delwave(string s_org, DataSet ds_tmp,string s_user)
    {
        int i_count;
        string s_str;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //循环删除明细
            for (int i = 0; i < ds_tmp.Tables[0].Rows.Count; i++)
            {
                s_str = "delete from " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and consignor = '" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and wave_no='" + ds_tmp.Tables[0].Rows[i]["wave_no"].ToString().Trim() + "' and so_no='" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
                //更改出库单为波次未做成
                s_str = "update " + g_usespace + ".so_ship_header set wave_flag = '0',main_dist='C',update_time=sysdate,updater='" + s_user + "' where inv_org = '" + s_org + "' and consignor='" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and so_no ='" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            //出来判断该波次是否还有相应的数据，如果没有则删除相应的波次好
            s_str = "select count(*) from " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and wave_no ='" + ds_tmp.Tables[0].Rows[0]["wave_no"].ToString().Trim() + "'";
            command.CommandText = s_str;
            i_count = dbCenter.ExecuteScalar(command);
            if (i_count <= 0) //说明没有数据了删除表头
            {
                s_str = "delete from " + g_usespace + ".so_ship_wave where inv_org = '" + s_org + "' and wave_no='" + ds_tmp.Tables[0].Rows[0]["wave_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw; 
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //一单拣货
    [WebMethod]
    public void oracle_exec_proc_billpick(string s_org, string s_consignor, string s_so_no, string s_wave, string s_preparer, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_BILL_PICK");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_wave", OracleType.Char, 20);
            command.Parameters["sp_wave"].Value = s_wave;
            command.Parameters.Add("sp_preparer", OracleType.Char, 20);
            command.Parameters["sp_preparer"].Value = s_preparer;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //正大富通一单拣货
    [WebMethod]
    public string oracle_exec_proc_billpick_new(string s_org, string s_consignor, string s_so_no, string s_wave, string s_preparer, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_BILL_PICK_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_wave", OracleType.Char, 20);
            command.Parameters["sp_wave"].Value = s_wave;
            command.Parameters.Add("sp_preparer", OracleType.Char, 20);
            command.Parameters["sp_preparer"].Value = s_preparer;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //正大富通一单拣货
    [WebMethod]
    public string oracle_exec_proc_billpick_geirf(string s_org, string s_consignor, string s_so_no, string s_wave, string s_preparer, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_BILL_PICK_GEIRF");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try  
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_wave", OracleType.Char, 20);
            command.Parameters["sp_wave"].Value = s_wave;
            command.Parameters.Add("sp_preparer", OracleType.Char, 20);
            command.Parameters["sp_preparer"].Value = s_preparer;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //二次备料拣货
    [WebMethod]
    public string oracle_exec_proc_BillRePick(DataSet ds_repick, string s_preparer, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_repick.Tables[0].Rows.Count; i++)
            {
                command.CommandText = g_usespace + ".SP_ORL_BILL_REPICK";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_repick.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_repick.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_so", OracleType.Char, 20);
                command.Parameters["sp_so"].Value = ds_repick.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("sp_wave", OracleType.Char, 20);
                command.Parameters["sp_wave"].Value = ds_repick.Tables[0].Rows[i]["wave_no"].ToString().Trim();
                command.Parameters.Add("sp_preparer", OracleType.Char, 20);
                command.Parameters["sp_preparer"].Value = s_preparer;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.Char, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //波次拣货
    [WebMethod]
    public void oracle_exec_proc_wavepick(string s_org, string s_consignor, string s_wave, string s_preparer, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_WAVE_PICK");
        DatabaseController dbCenter = new DatabaseController();
        try
        { 
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_waveno", OracleType.Char, 20);
            command.Parameters["sp_waveno"].Value = s_wave;
            command.Parameters.Add("sp_preparer", OracleType.Char, 20);
            command.Parameters["sp_preparer"].Value = s_preparer;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //正大富通波次拣货
    [WebMethod]
    public string oracle_exec_proc_wavepick_new(string s_org, string s_consignor, string s_wave, string s_preparer, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_WAVE_PICK_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_waveno", OracleType.Char, 20);
            command.Parameters["sp_waveno"].Value = s_wave;
            command.Parameters.Add("sp_preparer", OracleType.Char, 20);
            command.Parameters["sp_preparer"].Value = s_preparer;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //调用存储过程
    //分配数量新增
    [WebMethod]
    public string oracle_exec_proc_allocadd(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, decimal d_qty, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_ALLOC_ADD");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_line;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_qty", OracleType.Number, 16);
            command.Parameters["sp_qty"].Value = d_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //分配数量修改
    [WebMethod]
    public string oracle_exec_proc_allocmodify(string s_org, DataSet ds_modify, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            decimal d_qty;
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_ORL_ALLOC_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_so", OracleType.Char, 20);
                command.Parameters["sp_so"].Value = ds_modify.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_bat", OracleType.Char, 12);
                command.Parameters["sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = d_qty;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.Char, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //分配数量删除
    [WebMethod]
    public string oracle_exec_proc_allocdel(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, decimal d_qty, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_ALLOC_DEL");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_line;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_qty", OracleType.Number, 16);
            command.Parameters["sp_qty"].Value = d_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.Char, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //出库单分配取消
    [WebMethod]
    public string oracle_exec_proc_alloccancel(string s_org, DataSet ds_alloc, string s_user)
    {
        string str_consignor, str_sono;
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_alloc.Tables[0].Rows.Count; i++)
            {
                str_consignor = ds_alloc.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_sono = ds_alloc.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_ORL_ALLOC_CANCEL";
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = str_consignor;
                command.Parameters.Add("sp_so", OracleType.Char, 20);
                command.Parameters["sp_so"].Value = str_sono;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.Char, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //拣货确认
    [WebMethod]
    public string oracle_pick_confirm(string s_org, DataSet dtst, string strsql, string s_consignor, string s_so_no, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, dtst);
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_ORL_PICK_LIST";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20); 
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                dbCenter.Rollback();
            } 
            else
            {
                dbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }
    //波次拣货确认
    [WebMethod]
    public string oracle_wave_confirm(string s_org, string s_consignor, string s_wave_no, string s_user, string s_flag)
    {
        //s_flag  0说明是分配到库位, 1 说明是分配到托盘批次
        string str_ls_middle;
        string str_sql;
        DataSet ds_so;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            str_sql = "select so_no from " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and wave_no = '" + s_wave_no + "' order by so_no";
            command.CommandType = CommandType.Text;
            command.CommandText = str_sql;
            ds_so = dbCenter.ExecuteQuery(command);
            dbCenter.BeginTransaction();
            if (ds_so.Tables[0].Rows.Count > 0) //说明有出库单要确认
            {
                for (int i = 0; i < ds_so.Tables[0].Rows.Count; i++)
                {
                    //首先更新状态是0的拣货信息到tmp_pick_qty_m
                    if (s_flag.Trim() == "0") //说明是分配到库位
                    {
                        str_sql = "update " + g_usespace + ".so_pick_detail set tmp_pick_qty_m = nvl(plan_pick_qty_m,0) - nvl(pick_qty_m,0),tmp_pick_qty_s = nvl(plan_pick_qty_s,0) - nvl(pick_qty_s,0) where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and so_no = '" +
                                  ds_so.Tables[0].Rows[i]["so_no"].ToString().Trim() + "' and batchno = '0' and pallet_no = '0' and pcik_status in ('0','3')";
                    }
                    else //说明是分配到托盘批次
                    {
                        str_sql = "update " + g_usespace + ".so_pick_detail set tmp_pick_qty_m = nvl(plan_pick_qty_m,0) - nvl(pick_qty_m,0),tmp_pick_qty_s = nvl(plan_pick_qty_s,0) - nvl(pick_qty_s,0) where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and so_no = '" +
                                  ds_so.Tables[0].Rows[i]["so_no"].ToString().Trim() + "' and pcik_status in ('0','3')";
                    }
                    command.CommandType = CommandType.Text;
                    command.CommandText = str_sql;
                    dbCenter.ExecuteNonQuery(command);
                    //然后调用存储过程确认
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_PICK_LIST";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = s_org;
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = s_consignor;
                    command.Parameters.Add("sp_so", OracleType.Char, 20);
                    command.Parameters["sp_so"].Value = ds_so.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
                //出来修改波次的状态
                str_sql = "update " + g_usespace + ".so_ship_wave set confirm_day = to_char(sysdate,'YYYY.MM.DD'),confirmer='" + s_user + "',wave_status='2',main_dist='C',update_time=sysdate,updater='" + s_user + "' where " +
                          "inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and wave_no = '" + s_wave_no + "'";
                command.CommandType = CommandType.Text;
                command.CommandText = str_sql;
                dbCenter.ExecuteNonQuery(command);
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //定尺物料波次拣货确认
    [WebMethod]
    public string oracle_regular_wave_confirm(string s_org, string s_consignor, string s_wave_no, DataSet ds_confirm, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_confirm.Tables[0].Rows.Count > 0) //说明有出库单要确认
            {
                for (int i = 0; i < ds_confirm.Tables[0].Rows.Count; i++)
                {
                    if (System.Convert.ToDecimal(ds_confirm.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim()) > 0)
                    {
                        //然后调用存储过程确认
                        command.CommandType = CommandType.StoredProcedure;
                        command.CommandText = g_usespace + ".SP_ORL_PICK_CIMC1";
                        command.Parameters.Add("sp_org", OracleType.Char, 15);
                        command.Parameters["sp_org"].Value = s_org;
                        command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                        command.Parameters["sp_csgor"].Value = s_consignor;
                        command.Parameters.Add("sp_waveno", OracleType.Char, 20);
                        command.Parameters["sp_waveno"].Value = s_wave_no;
                        command.Parameters.Add("sp_locno", OracleType.Char, 20);
                        command.Parameters["sp_locno"].Value = ds_confirm.Tables[0].Rows[i]["loc_no"].ToString().Trim(); ;
                        command.Parameters.Add("sp_sku", OracleType.Char, 30);
                        command.Parameters["sp_sku"].Value = ds_confirm.Tables[0].Rows[i]["sku"].ToString().Trim(); ;
                        command.Parameters.Add("sp_lotno", OracleType.Char, 20);
                        command.Parameters["sp_lotno"].Value = ds_confirm.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                        command.Parameters.Add("sp_qtys", OracleType.Number, 16);
                        command.Parameters["sp_qtys"].Value = System.Convert.ToDecimal(ds_confirm.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                        command.Parameters.Add("sp_user", OracleType.Char, 10);
                        command.Parameters["sp_user"].Value = s_user;
                        command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                        command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                        dbCenter.ExecuteNonQuery(command);
                        if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                        {
                            str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                            break;
                        }
                        command.Parameters.Clear();
                    }
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //调用存储过程
    //拣货数量新增
    [WebMethod]
    public string oracle_exec_proc_pickadd(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, decimal d_qty, string s_user, string s_flag)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PICK_ADD");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_line;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_qty", OracleType.Number, 16);
            command.Parameters["sp_qty"].Value = d_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_flag", OracleType.Char, 1);
            command.Parameters["sp_flag"].Value = s_flag;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //缺补货确认
    [WebMethod]
    public string oracle_exec_proc_shortpick(DataSet ds_data, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_data.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_data.Tables[0].Rows.Count; i++)
                {
                    if (i > 0) command.Parameters.Clear();
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_SHORT_PICK";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_data.Tables[0].Rows[i]["sp_org"].ToString().Trim();
                    command.Parameters.Add("sp_consignor", OracleType.Char, 15);
                    command.Parameters["sp_consignor"].Value = ds_data.Tables[0].Rows[i]["sp_consignor"].ToString().Trim();
                    command.Parameters.Add("sp_sono", OracleType.Char, 20);
                    command.Parameters["sp_sono"].Value = ds_data.Tables[0].Rows[i]["sp_sono"].ToString().Trim();
                    command.Parameters.Add("sp_line_no", OracleType.Int32);
                    command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_data.Tables[0].Rows[i]["sp_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_sku", OracleType.Char, 30);
                    command.Parameters["sp_sku"].Value = ds_data.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                    command.Parameters.Add("sp_location", OracleType.Char, 20);
                    command.Parameters["sp_location"].Value = ds_data.Tables[0].Rows[i]["sp_location"].ToString().Trim();
                    command.Parameters.Add("sp_batchno", OracleType.Char, 12);
                    command.Parameters["sp_batchno"].Value = ds_data.Tables[0].Rows[i]["sp_batchno"].ToString().Trim();
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = ds_data.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                    command.Parameters.Add("sp_qty", OracleType.Number, 16);
                    command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_data.Tables[0].Rows[i]["sp_qty"].ToString().Trim());
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.Char, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //portal拣货
    //拣货数量新增
    [WebMethod]
    public string oracle_exec_proc_portalpick(string s_org, DataSet ds_portal, DataSet ds_box, string s_user, string s_flag)
    {
        string strsql;
        OracleCommand command;
        command = new OracleCommand();
        //g_usespace + ".SP_ORL_PICK_ADD"
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //首先更新箱标在哪个拣货单
            if (ds_box.Tables[0].Rows.Count > 0) //说明有箱标存在
            {
                for (int i = 0; i < ds_box.Tables[0].Rows.Count; i++)
                {
                    strsql = "update " + g_usespace + ".inv_sku_rfid set so_no = '" + ds_box.Tables[0].Rows[i]["so_no"].ToString().Trim() + "',so_line_no=" + ds_box.Tables[0].Rows[i]["so_line_no"].ToString().Trim() +
                             " where inv_org = '"+s_org+"' and consignor = '" + ds_box.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and sku = '" + ds_box.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and box_rfid = '" +
                             ds_box.Tables[0].Rows[i]["box_rfid"].ToString().Trim() + "' and location_code = '" + ds_box.Tables[0].Rows[i]["location_code"].ToString().Trim() + "' and pallet_no = '" + ds_box.Tables[0].Rows[i]["pallet_no"].ToString().Trim() +"'";
                    command.CommandType = CommandType.Text;
                    command.CommandText = strsql;
                    dbCenter.ExecuteNonQuery(command);
                }
            }
            for (int i = 0; i < ds_portal.Tables[0].Rows.Count; i++)
            {
                command.Parameters.Clear();
                command.CommandType = CommandType.StoredProcedure; 
                command.CommandText = g_usespace + ".SP_ORL_PICK_ADD";
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_portal.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_so", OracleType.Char, 20);
                command.Parameters["sp_so"].Value = ds_portal.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_portal.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_portal.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_portal.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_bat", OracleType.Char, 12);
                command.Parameters["sp_bat"].Value = ds_portal.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_portal.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = Math.Round(System.Convert.ToDecimal(ds_portal.Tables[0].Rows[i]["stock_qty_m"].ToString().Trim()), 4);
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_flag", OracleType.Char, 1);
                command.Parameters["sp_flag"].Value = s_flag;
                command.Parameters.Add("sp_out", OracleType.VarChar, 50);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //拣货数量
    [WebMethod]
    public string oracle_exec_proc_pickmodify(string s_org, DataSet ds_modify, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            decimal d_qty;
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_ORL_PICK_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_so", OracleType.Char, 20);
                command.Parameters["sp_so"].Value = ds_modify.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_bat", OracleType.Char, 12);
                command.Parameters["sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batch_no"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = d_qty;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //拣货数量删除
    [WebMethod]
    public string oracle_exec_proc_pickdel(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet,decimal d_qty, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PICK_DEL");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_line;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char,15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_qty", OracleType.Number, 16);
            command.Parameters["sp_qty"].Value = d_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //拣货数量取
    [WebMethod]
    public string oracle_exec_proc_pickcancel(string s_org, DataSet ds_pick, string s_user)
    {
        string str_consignor, str_sono;
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_pick.Tables[0].Rows.Count; i++)
            {
                str_consignor = ds_pick.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_sono = ds_pick.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_ORL_PICK_CANCEL";
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = str_consignor;
                command.Parameters.Add("sp_so", OracleType.Char, 20);
                command.Parameters["sp_so"].Value = str_sono;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货确认
    [WebMethod]
    public string oracle_ship_confirm(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_ORL_SHIP_CONFIRM";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_so", OracleType.Char, 20);
                    command.Parameters["sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")  
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货明细确认
    [WebMethod]
    public string oracle_ship_confirm_detail(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    if (dtst.Tables[0].Rows[i]["check1"].ToString().Trim() == "1")
                    {
                        if (System.Convert.ToDecimal(dtst.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim()) > 0)
                        {
                            command.CommandText = g_usespace + ".SP_ORL_SHIP_CONFIRM_DETAIL";
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.Add("sp_org", OracleType.Char, 15);
                            command.Parameters["sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                            command.Parameters["sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                            command.Parameters.Add("sp_so", OracleType.Char, 20);
                            command.Parameters["sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                            command.Parameters.Add("sp_line_no", OracleType.Int32);
                            command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(dtst.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                            command.Parameters.Add("sp_loc", OracleType.Char, 20);
                            command.Parameters["sp_loc"].Value = dtst.Tables[0].Rows[i]["location_code"].ToString().Trim();
                            command.Parameters.Add("sp_bat", OracleType.Char, 12);
                            command.Parameters["sp_bat"].Value = dtst.Tables[0].Rows[i]["batchno"].ToString().Trim();
                            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                            command.Parameters["sp_pallet"].Value = dtst.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                            command.Parameters.Add("sp_qty", OracleType.Number, 16);
                            command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(dtst.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                            command.Parameters.Add("sp_user", OracleType.Char, 10);
                            command.Parameters["sp_user"].Value = s_user;
                            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                            dbCenter.ExecuteNonQuery(command);
                            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                            {
                                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                                break;
                            }
                            command.Parameters.Clear();
                        }
                    }
                }  
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货明细取消
    [WebMethod]
    public string oracle_ship_cancel_detail(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_ORL_SHIP_CANCEL_DETAIL";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_so", OracleType.Char, 20);
                    command.Parameters["sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("sp_line_no", OracleType.Int32);
                    command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(dtst.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_delivery_no", OracleType.Int32);
                    command.Parameters["sp_delivery_no"].Value = System.Convert.ToInt32(dtst.Tables[0].Rows[i]["delivery_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_loc", OracleType.Char, 20);
                    command.Parameters["sp_loc"].Value = dtst.Tables[0].Rows[i]["location_code"].ToString().Trim();
                    command.Parameters.Add("sp_bat", OracleType.Char, 12);
                    command.Parameters["sp_bat"].Value = dtst.Tables[0].Rows[i]["batchno"].ToString().Trim();
                    command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                    command.Parameters["sp_pallet"].Value = dtst.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("sp_memo", OracleType.VarChar, 200);
                    command.Parameters["sp_memo"].Value = dtst.Tables[0].Rows[i]["memo"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "1")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货取消
    [WebMethod]
    public string oracle_ship_cancel(string s_org, string s_consignor, string s_so_no, string s_memo, string s_user)
    {
        OracleCommand command;  
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //调用存储过程确认
            command.CommandText = g_usespace + ".SP_ORL_SHIP_CANCEL";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_memo", OracleType.VarChar, 200);
            command.Parameters["sp_memo"].Value = s_memo;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 256);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() == "1") //成功
            {
                dbCenter.Commit();
            }
            else  //失败
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }


    //出库单关闭
    [WebMethod]
    public string oracle_so_close(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_ORL_SO_CLOSE";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_so", OracleType.Char, 20);
                    command.Parameters["sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //强制补货做成
    [WebMethod]
    public string oracle_exec_proc_replecal(string s_org, string s_consignor, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_REPLE_CAL");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //正大富通版强制补货做成
    [WebMethod]
    public string oracle_exec_proc_replecal_new(string s_org, string s_consignor, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_REPLE_CAL_NEW");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //补货单删除
    [WebMethod]
    public string oracle_exec_proc_repledelbill(string s_org, string s_consignor, string s_reple ,string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_REPLE_DELBILL");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_reple", OracleType.Char, 20);
            command.Parameters["sp_reple"].Value = s_reple;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //补货明细单删除
    [WebMethod]
    public string oracle_exec_proc_repledel(string s_org, string s_consignor, string s_reple, int s_line, string s_loc, string s_bat, string s_pallet, string s_flag, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_REPLE_DEL");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_reple", OracleType.Char, 20);
            command.Parameters["sp_reple"].Value = s_reple;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = s_line;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_flag", OracleType.Char, 2);
            command.Parameters["sp_flag"].Value = s_flag;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() == "0")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //判断修改或删除的拣货数据回到的库位是否有效
    [WebMethod]
    public string oracle_exec_proc_pickloc(string s_org, string s_consignor, string s_so_no, int i_lineno, string s_batch, string s_loc, string s_pallet)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PICK_LOC");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_lineno", OracleType.Int32);
            command.Parameters["sp_lineno"].Value = i_lineno;
            command.Parameters.Add("sp_batch", OracleType.Char, 12);
            command.Parameters["sp_batch"].Value = s_batch;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //判断修改或删除的拣货数据回到的库位是否有效
    [WebMethod]
    public string oracle_exec_proc_pickloclist(string s_org, string s_consignor, string s_so_no)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PICK_LOCLIST");
        DatabaseController dbCenter = new DatabaseController();
        try
        { 
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //出库单分单存储过程
    [WebMethod]
    public string oracle_exec_proc_billsplit(string s_org, string s_consignor, string s_eas_no, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_BILL_SPLIT");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_eas_no", OracleType.Char, 20);
            command.Parameters["sp_eas_no"].Value = s_eas_no;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //新出库单分单存储过程
    [WebMethod]
    public string oracle_exec_proc_sosplit_new(string s_org, string s_consignor, string s_eas_no, string str_flag, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_SO_SPLIT_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_eas_no", OracleType.Char, 20);
            command.Parameters["sp_eas_no"].Value = s_eas_no;
            command.Parameters.Add("sp_split_flag", OracleType.Char, 1);
            command.Parameters["sp_split_flag"].Value = str_flag;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }


    //新收货单分单存储过程
    [WebMethod]
    public string oracle_exec_proc_asnsplit_new(string s_org, string s_consignor, string s_order_no, string str_flag,  string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_ASN_SPLIT_NEW");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_order_no", OracleType.Char, 20);
            command.Parameters["sp_order_no"].Value = s_order_no;
            command.Parameters.Add("sp_split_flag", OracleType.Char, 1);
            command.Parameters["sp_split_flag"].Value = str_flag;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle;
    }
    #endregion
    #region 库存管理的函数(移动，调整，盘点，转移，冻结)
    //盘点差异做成调整单
    [WebMethod]
    public void oracle_exec_proc_chkadjust(string s_org, string s_checkno, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_MAKE_ADJUST");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_checkno", OracleType.Char, 20);
            command.Parameters["sp_checkno"].Value = s_checkno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //批量更新盘点数据
    [WebMethod]
    public void oracle_refresh_checkdb(string s_org, DataSet dtst, string strsql, string s_checkno, string str_userid)
    {
        string s_str;
        int i_count;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, dtst);
            //判断盘点是否全部确认完成，如果是改状态是3，否则2
            s_str = "select count(*) from " + g_usespace + ".inv_check_detail where inv_org = '"+s_org+"' and check_no ='" + s_checkno + "' and check_status ='0'";
            command.CommandText = s_str;
            i_count = dbCenter.ExecuteScalar(command);
            s_str = "update " + g_usespace + ".inv_check_header set ";
            if (i_count > 0)//说明还没有收完
                s_str = s_str + "check_status = '2',";
            else
                s_str = s_str + "check_status = '3',";
            s_str = s_str + "main_dist = 'C',update_time=sysdate,updater='" + str_userid + "' where inv_org = '"+s_org+"' and check_no ='" + s_checkno + "'";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //批量更新复核盘点数据
    [WebMethod]
    public void oracle_refresh_checkdb_review(string s_org, DataSet dtst, string strsql, string s_checkno, int i_number, string str_userid)
    {
        string s_str;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, dtst);
            //判断盘点是否全部确认完成，根据盘点次数更新盘点数量
            s_str = "update " + g_usespace + ".inv_check_detail set check_qty_m = (select nvl(a.check_qty_m,0) from " + g_usespace + ".inv_check_detail_review a where a.inv_org = " + g_usespace + ".inv_check_detail.inv_org " +
                    " and a.check_no = " + g_usespace + ".inv_check_detail.check_no and a.check_line_no = " + g_usespace + ".inv_check_detail.check_line_no and a.inv_org = '" + s_org + "' and a.check_no = '" + s_checkno + "' " +
                    " and a.check_number = " + i_number.ToString().Trim() + " and a.check_status = '1'),check_qty_s = (select nvl(a.check_qty_s,0) from " + g_usespace + ".inv_check_detail_review a where a.inv_org = " + g_usespace + ".inv_check_detail.inv_org " +
                    " and a.check_no = " + g_usespace + ".inv_check_detail.check_no and a.check_line_no = " + g_usespace + ".inv_check_detail.check_line_no and a.inv_org = '" + s_org + "' and a.check_no = '" + s_checkno + "' " +
                    " and a.check_number = " + i_number.ToString().Trim() + " and a.check_status = '1'),main_dist = 'C',updater = '" + str_userid + "',update_time = sysdate where inv_org = '" + s_org + "' and check_no ='" + s_checkno + "' " +
                    " and exists (select 1 from " + g_usespace + ".inv_check_detail_review a where a.inv_org = " + g_usespace + ".inv_check_detail.inv_org " +
                    " and a.check_no = " + g_usespace + ".inv_check_detail.check_no and a.check_line_no = " + g_usespace + ".inv_check_detail.check_line_no and a.inv_org = '" + s_org + "' and a.check_no = '" + s_checkno + "' " +
                    " and a.check_number = " + i_number.ToString().Trim() + " and a.check_status = '1')";
            command.CommandText = s_str;
            dbCenter.ExecuteNonQuery(command);
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //库存调整明细新增
    [WebMethod]
    public void oracle_add_adjdetail(string s_org, DataSet ds_adj, string str_userid)
    {
        string s_str;
        int i_adj_no;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //得到最大行号
            s_str = "select nvl(max(adjust_line_no),0) from " + g_usespace + ".inv_adjust_detail where inv_org = '" + s_org + "' and consignor = '" + ds_adj.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' " +
                    "and adjust_no ='" + ds_adj.Tables[0].Rows[0]["adjust_no"].ToString().Trim() + "'";
            command.CommandText = s_str;
            i_adj_no = dbCenter.ExecuteScalar(command);
            //循环进行调整明细新增
            for (int i = 0; i < ds_adj.Tables[0].Rows.Count; i++)
            {
                i_adj_no = i_adj_no + 1;
                //插入调整明细
                s_str = "insert into " + g_usespace + ".inv_adjust_detail(inv_org,consignor,	adjust_no,	adjust_line_no,	batchno," +
                                                                        "sku,		sku_name,	main_sub_flag,	convert_modulus," +
                                                                        "location_code,	pallet_no,	from_stock_qty_m,	from_stock_qty_s," +
                                                                        "to_stock_qty_m,	to_stock_qty_s,	from_cubage,	from_gross_weight," +
                                                                        "from_net_weight,	to_cubage,	to_gross_weight,	to_net_weight," +
                                                                        "from_order_price,	from_unit,	to_order_price,	to_unit," +
                                                                        "adjust_status,	confirm_flag,	confirm_day,	confirmer," +
                                                                        "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                        "standby_5,	standby_6,	standby_7,	main_dist,   made_time,	maker," +
                                                                        "lot_attribute1,lot_attribute2,lot_attribute3,lot_attribute4,lot_attribute5," +
                                                                        "lot_attribute6,lot_attribute7,lot_attribute8,lot_attribute9,lot_attribute10," +
                                                                        "lot_attribute11,lot_attribute12,lot_attribute13,lot_attribute14,lot_attribute15)" +
                        " values ('" + s_org + "','" + ds_adj.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["adjust_no"].ToString().Trim() + "'," + System.Convert.ToString(i_adj_no) + ",'" + ds_adj.Tables[0].Rows[i]["batchno"].ToString().Trim() + "','" +
                        ds_adj.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["sku_name"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_adj.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" +
                        ds_adj.Tables[0].Rows[i]["location_code"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "'," + ds_adj.Tables[0].Rows[i]["from_stock_qty_m"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["from_stock_qty_s"].ToString().Trim() + "," +
                        ds_adj.Tables[0].Rows[i]["to_stock_qty_m"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_stock_qty_s"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["from_cubage"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["from_gross_weight"].ToString().Trim() + "," +
                        ds_adj.Tables[0].Rows[i]["from_net_weight"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_cubage"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_gross_weight"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_net_weight"].ToString().Trim() + "," +
                        ds_adj.Tables[0].Rows[i]["from_order_price"].ToString().Trim() + ",'" + ds_adj.Tables[0].Rows[i]["from_unit"].ToString().Trim() + "'," + ds_adj.Tables[0].Rows[i]["to_order_price"].ToString().Trim() + ",'" + ds_adj.Tables[0].Rows[i]["to_unit"].ToString().Trim() + "'," +
                        "'0','','','','','','','','',0,0,'A',sysdate,'" + str_userid + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "'" +
                        ",'" + ds_adj.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "'" +
                        ",'" + ds_adj.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "')";
                command.CommandText = s_str;
                dbCenter.ExecuteNonQuery(command);
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }
          
    //调用存储过程
    //库存调整表头确认
    [WebMethod]
    public string oracle_exec_proc_adjconlist(string s_org, string s_consignor, string s_adjno, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_ADJ_CON_LIST");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_customer", OracleType.Char, 15);
            command.Parameters["sp_customer"].Value = s_consignor;
            command.Parameters.Add("sp_adjustno", OracleType.Char, 20);
            command.Parameters["sp_adjustno"].Value = s_adjno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }


    //无库存调整明细增加
    [WebMethod]
    public string oracle_exec_proc_adj_add_noinventery(DataSet ds_adjcon, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_adjcon.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_adjcon.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_ORL_ADJUST_ADD_NEW";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_adjcon.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_customer", OracleType.Char, 15);
                    command.Parameters["sp_customer"].Value = ds_adjcon.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_sku", OracleType.Char, 30);
                    command.Parameters["sp_sku"].Value = ds_adjcon.Tables[0].Rows[i]["sku"].ToString().Trim();
                    command.Parameters.Add("sp_pack", OracleType.Char, 30);
                    command.Parameters["sp_pack"].Value = ds_adjcon.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                    command.Parameters.Add("sp_loc", OracleType.Char, 20);
                    command.Parameters["sp_loc"].Value = ds_adjcon.Tables[0].Rows[i]["location_code"].ToString().Trim();
                    command.Parameters.Add("sp_lot3", OracleType.Char, 20);
                    command.Parameters["sp_lot3"].Value = ds_adjcon.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim();
                    command.Parameters.Add("sp_lot5", OracleType.Char, 20);
                    command.Parameters["sp_lot5"].Value = ds_adjcon.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //实时盘点调整单做成
    [WebMethod]
    public string oracle_exec_proc_checktimely_makeadjust(string s_org, string s_checkno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_CKTIMELY_MAKE_ADJUST");
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_checkno", OracleType.Char, 20);
            command.Parameters["sp_checkno"].Value = s_checkno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 200);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //库存调整明细确认
    [WebMethod]
    public string oracle_exec_proc_adjcon(string s_org, DataSet ds_adjcon, string s_user)
    {
        string s_consignor, s_adjno;
        int s_adjline;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_adjcon.Tables[0].Rows.Count; i++)
            {
                s_consignor = ds_adjcon.Tables[0].Rows[i]["consignor"].ToString().Trim();
                s_adjno = ds_adjcon.Tables[0].Rows[i]["adjust_no"].ToString().Trim();
                s_adjline = System.Convert.ToInt32(ds_adjcon.Tables[0].Rows[i]["adjust_line_no"].ToString().Trim());
                command.CommandText = g_usespace + ".SP_ORL_ADJ_CONFIRM";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_customer", OracleType.Char, 15);
                command.Parameters["sp_customer"].Value = s_consignor;
                command.Parameters.Add("sp_adjustno", OracleType.Char, 20);
                command.Parameters["sp_adjustno"].Value = s_adjno;
                command.Parameters.Add("sp_adjustline", OracleType.Int32);
                command.Parameters["sp_adjustline"].Value = s_adjline;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user; 
                command.Parameters.Add("sp_out", OracleType.VarChar, 50);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "temp")
                {
                    dbCenter.Rollback();
                    dbCenter.CloseConnection();
                    return command.Parameters["sp_out"].Value.ToString().Trim();
                }
                command.Parameters.Clear();
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return "";
    }

    //调用存储过程
    //库存冻结生成
    [WebMethod]
    public void oracle_exec_proc_makefreeze(string s_org, DataSet ds_freeze, string s_user)
    {
        string s_consignor,s_pack, s_sku, s_location, s_pallet, s_type, s_reason;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_freeze.Tables[0].Rows.Count; i++)
            {
                s_consignor = ds_freeze.Tables[0].Rows[i]["consignor"].ToString().Trim();
                s_sku = ds_freeze.Tables[0].Rows[i]["sku"].ToString().Trim();
                s_location = ds_freeze.Tables[0].Rows[i]["location_code"].ToString().Trim();
                s_pallet = ds_freeze.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                s_type = ds_freeze.Tables[0].Rows[i]["freeze_type"].ToString().Trim();
                s_reason = ds_freeze.Tables[0].Rows[i]["freeze_reason"].ToString().Trim();
                s_pack = ds_freeze.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.CommandText = g_usespace + ".SP_ORL_FREEZE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_customer", OracleType.Char, 15);
                command.Parameters["sp_customer"].Value = s_consignor;
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = s_sku;
                command.Parameters.Add("sp_pack", OracleType.Char, 20);
                command.Parameters["sp_pack"].Value = s_pack;
                command.Parameters.Add("sp_location", OracleType.Char, 20); 
                command.Parameters["sp_location"].Value = s_location;
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = s_pallet;
                command.Parameters.Add("sp_type", OracleType.Char, 1);
                command.Parameters["sp_type"].Value = s_type;
                command.Parameters.Add("sp_reason", OracleType.Char, 2);
                command.Parameters["sp_reason"].Value = s_reason;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                dbCenter.ExecuteNonQuery(command);
                command.Parameters.Clear();
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //库存解冻
    [WebMethod]
    public void oracle_exec_proc_unfreeze(string s_org, string s_consignor, string s_freeze, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_ORL_UNFREEZE";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_customer", OracleType.Char, 15);
            command.Parameters["sp_customer"].Value = s_consignor;
            command.Parameters.Add("sp_freezeno", OracleType.Char, 20);
            command.Parameters["sp_freezeno"].Value = s_freeze;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //正大富通三包移库建议库位计算
    [WebMethod]
    public string oracle_move_calloc_new(string s_org, string s_consignor, decimal d_qtym, string s_sku, string s_pack, string s_box, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_ORL_MOVE_CAL_NEW";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_qty", OracleType.Number, 16);
            command.Parameters["sp_qty"].Value = d_qtym;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_pack", OracleType.Char, 30);
            command.Parameters["sp_pack"].Value = s_pack;
            command.Parameters.Add("sp_box", OracleType.Char, 30);
            command.Parameters["sp_box"].Value = s_box;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_loc", OracleType.Char, 100);
            command.Parameters["sp_loc"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_loc"].Value.ToString().Trim();
    }

    //移库确认
    [WebMethod]
    public string oracle_move_confirm(string s_org, DataSet dtst, string strsql, string s_consignor, string s_move_no, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, dtst);  
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_ORL_MOVE_CONFIRM";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_moveno", OracleType.Char, 20);
            command.Parameters["sp_moveno"].Value = s_move_no;  
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() == "0")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //移库数量新增
    [WebMethod]
    public string oracle_exec_proc_moveadd(string s_org, string s_consignor, string s_move_no, int i_line, string s_outloc, string s_inloc, string s_pallet,string s_ipallet, string s_bat, decimal d_qty, decimal d_pallet_qty,string s_outware, string s_inware, string s_user, string s_flag)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_MOVE_ADD");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_moveno", OracleType.Char, 20);
            command.Parameters["sp_moveno"].Value = s_move_no;
            command.Parameters.Add("sp_lineon", OracleType.Int32);
            command.Parameters["sp_lineon"].Value = i_line;
            command.Parameters.Add("sp_moveout", OracleType.Char, 20);
            command.Parameters["sp_moveout"].Value = s_outloc;
            command.Parameters.Add("sp_movein", OracleType.Char, 20);
            command.Parameters["sp_movein"].Value = s_inloc;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_inpallet", OracleType.Char, 15);
            command.Parameters["sp_inpallet"].Value = s_ipallet;
            command.Parameters.Add("sp_batch", OracleType.Char, 12);
            command.Parameters["sp_batch"].Value = s_bat;
            command.Parameters.Add("sp_use_qty", OracleType.Number,16);
            command.Parameters["sp_use_qty"].Value = d_qty;
            command.Parameters.Add("sp_pallet_qtym", OracleType.Number,16);
            command.Parameters["sp_pallet_qtym"].Value = d_pallet_qty;
            command.Parameters.Add("sp_outloc", OracleType.Char, 5);
            command.Parameters["sp_outloc"].Value = s_outware;
            command.Parameters.Add("sp_inloc", OracleType.Char, 5);
            command.Parameters["sp_inloc"].Value = s_inware;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_flag", OracleType.Char, 1);
            command.Parameters["sp_flag"].Value = s_flag;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() == "0") //说明成功
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    } 

    //调用存储过程
    //移库数量修改
    [WebMethod]
    public void oracle_exec_proc_movemodify(string s_org, DataSet ds_modify, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            decimal d_qty;
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_ORL_MOVE_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_move_no", OracleType.Char, 20);
                command.Parameters["sp_move_no"].Value = ds_modify.Tables[0].Rows[i]["move_no"].ToString().Trim();
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["move_line_no"].ToString().Trim());
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_bat", OracleType.Char, 12);
                command.Parameters["sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batch_no"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_in_pallet", OracleType.Char, 15);
                command.Parameters["sp_in_pallet"].Value = ds_modify.Tables[0].Rows[i]["in_pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number,16);
                command.Parameters["sp_qty"].Value = d_qty;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                dbCenter.ExecuteNonQuery(command);
                command.Parameters.Clear();
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally  
        {
            dbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //移库数量删除
    [WebMethod]
    public void oracle_exec_proc_movedel(string s_org, string s_consignor, string s_move_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_MOVE_DEL");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_move_no", OracleType.Char, 20);
            command.Parameters["sp_move_no"].Value = s_move_no;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_line;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }
     
    //补货确认
    [WebMethod]
    public string oracle_reple_confirm(string s_org, DataSet dtst, string strsql, string s_consignor, string s_move_no, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, dtst);
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_ORL_REPLEN_CONFIRM";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_moveno", OracleType.Char, 20);
            command.Parameters["sp_moveno"].Value = s_move_no;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() == "0")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //补货数量新增
    [WebMethod]
    public string oracle_exec_proc_repleadd(string s_org, string s_consignor, string s_move_no, int i_line, string s_outloc, string s_inloc, string s_pallet,string s_ipallet, string s_bat, decimal d_qty, decimal d_pallet_qty, string s_user, string s_flag)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_REPLEN_ADD");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_moveno", OracleType.Char, 20);
            command.Parameters["sp_moveno"].Value = s_move_no;
            command.Parameters.Add("sp_lineon", OracleType.Int32);
            command.Parameters["sp_lineon"].Value = i_line;
            command.Parameters.Add("sp_moveout", OracleType.Char, 20);
            command.Parameters["sp_moveout"].Value = s_outloc;
            command.Parameters.Add("sp_movein", OracleType.Char, 20);
            command.Parameters["sp_movein"].Value = s_inloc;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_inpallet", OracleType.Char, 15);
            command.Parameters["sp_inpallet"].Value = s_ipallet;
            command.Parameters.Add("sp_batch", OracleType.Char, 12);
            command.Parameters["sp_batch"].Value = s_bat;
            command.Parameters.Add("sp_use_qty", OracleType.Number, 16);
            command.Parameters["sp_use_qty"].Value = d_qty;
            command.Parameters.Add("sp_pallet_qtym", OracleType.Number, 16);
            command.Parameters["sp_pallet_qtym"].Value = d_pallet_qty;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_flag", OracleType.Char, 1);
            command.Parameters["sp_flag"].Value = s_flag;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() == "0")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //补货数量修改
    [WebMethod]
    public void oracle_exec_proc_replemodify(string s_org, DataSet ds_modify, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            decimal d_qty;
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_ORL_REPLEN_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_move_no", OracleType.Char, 20);
                command.Parameters["sp_move_no"].Value = ds_modify.Tables[0].Rows[i]["move_no"].ToString().Trim();
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["move_line_no"].ToString().Trim());
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_bat", OracleType.Char, 12);
                command.Parameters["sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batch_no"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_in_pallet", OracleType.Char, 15);
                command.Parameters["sp_in_pallet"].Value = ds_modify.Tables[0].Rows[i]["in_pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = d_qty;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                dbCenter.ExecuteNonQuery(command);
                command.Parameters.Clear();
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //补货数量删除
    [WebMethod]
    public void oracle_exec_proc_repledelete(string s_org, string s_consignor, string s_move_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_REPLEN_DEL");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_move_no", OracleType.Char, 20);
            command.Parameters["sp_move_no"].Value = s_move_no;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_line;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku;
            command.Parameters.Add("sp_loc", OracleType.Char, 20);
            command.Parameters["sp_loc"].Value = s_loc;
            command.Parameters.Add("sp_bat", OracleType.Char, 12);
            command.Parameters["sp_bat"].Value = s_bat;
            command.Parameters.Add("sp_pallet", OracleType.Char, 15);
            command.Parameters["sp_pallet"].Value = s_pallet;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //移库单关闭
    [WebMethod]
    public void oracle_exec_proc_moveclose(string s_org, string s_consignor, string s_move_no, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_MOVE_COLSE");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_consignor", OracleType.Char, 15);
            command.Parameters["sp_consignor"].Value = s_consignor;
            command.Parameters.Add("sp_moveno", OracleType.Char, 20);
            command.Parameters["sp_moveno"].Value = s_move_no;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
    }

    //转移确认
    [WebMethod]
    public string oracle_exec_proc_transfer(string s_org, DataSet ds_transfer, string s_user)
    {
        string str_sql;
        string str_ls_middle;
        string str_tr_no;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //得到单据号
            str_tr_no = "TR" + oracle_get_accountno(s_org, "TRANS_NO").ToString("00000000");
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            //首先插入表头信息
            str_sql = "insert into " + g_usespace + ".inv_transfer_header(inv_org,	transfer_no,	transfer_type,	transfer_reason," +
                                                                    "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                    "standby_5,	standby_6,	standby_7,	transfer_status," +
                                                                    "memo,		main_dist,	made_time,	maker)" +
                                                        " values ('" + s_org + "','" + str_tr_no + "','0',''," +
                                                                 "'','','',''," +
                                                                 "'',0,0,'1'," +
                                                                 "'','A',sysdate,'" + s_user + "')";
            command.CommandType = CommandType.Text;
            command.CommandText = str_sql;
            dbCenter.ExecuteNonQuery(command);
            //循环进行库存转移
            for (int i = 0; i < ds_transfer.Tables[0].Rows.Count; i++)
            {
                //在执行存储过程
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_ORL_TRANSFER";
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_transfer_no", OracleType.Char, 20);
                command.Parameters["sp_transfer_no"].Value = str_tr_no;
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = i + 1;
                command.Parameters.Add("sp_batchno", OracleType.Char, 12);
                command.Parameters["sp_batchno"].Value = ds_transfer.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_transfer.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_transfer.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_lottrs", OracleType.Char, 315);
                command.Parameters["sp_lottrs"].Value = ds_transfer.Tables[0].Rows[i]["str_lottrs"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_transfer.Tables[0].Rows[i]["trans_qty_m"].ToString().Trim());
                command.Parameters.Add("sp_memo", OracleType.VarChar, 200);
                command.Parameters["sp_memo"].Value = ds_transfer.Tables[0].Rows[i]["memo"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 255);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                    command.Parameters.Clear();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //判断移库的库位是否有效
    [WebMethod]
    public string oracle_exec_proc_moveloc(string s_org, string s_consignor, string s_sku, string s_oloc, string s_iloc, decimal d_qty, string s_pack)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_CHECK_LOC");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_sku", OracleType.Char, 30);
            command.Parameters["sp_sku"].Value = s_sku; 
            command.Parameters.Add("sp_outloc", OracleType.Char, 20);
            command.Parameters["sp_outloc"].Value = s_oloc;
            command.Parameters.Add("sp_inloc", OracleType.Char, 20);
            command.Parameters["sp_inloc"].Value = s_iloc;
            command.Parameters.Add("sp_qty", OracleType.Number, 16);
            command.Parameters["sp_qty"].Value = d_qty;
            command.Parameters.Add("sp_pack", OracleType.Char, 20);
            command.Parameters["sp_pack"].Value = s_pack; 
            command.Parameters.Add("sp_putloc", OracleType.VarChar, 50);
            command.Parameters["sp_putloc"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        } 
        return command.Parameters["sp_putloc"].Value.ToString().Trim();
    }

    //portal生成盘点数据
    [WebMethod]
    public string oracle_exec_proc_portalcheck(string s_org, string s_loc1, string s_loc2,string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_PORTAL_CHECK");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_loc1", OracleType.Char, 20);
            command.Parameters["sp_loc1"].Value = s_loc1;
            command.Parameters.Add("sp_loc2", OracleType.Char, 20);
            command.Parameters["sp_loc2"].Value = s_loc2;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 50);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
   //         return command.Parameters["sp_out"].Value.ToString().Trim();
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //临时领料的存储过程
    [WebMethod]
    public string oracle_exec_proc_tempupdate(DataSet ds_tempupdate, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_tempupdate.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_TEMP_UPDATE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_org"].ToString().Trim();
                command.Parameters.Add("sp_consignor", OracleType.Char, 15);
                command.Parameters["sp_consignor"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_consignor"].ToString().Trim();
                command.Parameters.Add("sp_tkno", OracleType.Char, 20);
                command.Parameters["sp_tkno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_tkno"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("sp_location", OracleType.Char, 20);
                command.Parameters["sp_location"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_location"].ToString().Trim();
                command.Parameters.Add("sp_batchno", OracleType.Char, 12);
                command.Parameters["sp_batchno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_batchno"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_tempupdate.Tables[0].Rows[i]["sp_qty"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 200);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
            }
            dbCenter.Commit();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //快速出库的存储过程
    [WebMethod]
    public string oracle_exec_proc_quickout(DataSet ds_tempupdate, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        str_ls_middle = "";
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_tempupdate.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_QUICKOUT";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_org"].ToString().Trim();
                command.Parameters.Add("sp_consignor", OracleType.Char, 15);
                command.Parameters["sp_consignor"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_consignor"].ToString().Trim();
                command.Parameters.Add("sp_tkno", OracleType.Char, 20);
                command.Parameters["sp_tkno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_tkno"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("sp_location", OracleType.Char, 20);
                command.Parameters["sp_location"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_location"].ToString().Trim();
                command.Parameters.Add("sp_batchno", OracleType.Char, 12);
                command.Parameters["sp_batchno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_batchno"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_tempupdate.Tables[0].Rows[i]["sp_qty"].ToString().Trim());
                command.Parameters.Add("sp_reason", OracleType.VarChar, 200);
                command.Parameters["sp_reason"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_reason"].ToString().Trim();
                command.Parameters.Add("sp_customer", OracleType.VarChar, 100);
                command.Parameters["sp_customer"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_customer"].ToString().Trim();
                command.Parameters.Add("sp_equipment", OracleType.VarChar, 30);
                command.Parameters["sp_equipment"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_equipment"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 200);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "1")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }  
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //委外出库确认的存储过程
    [WebMethod]
    public string oracle_exec_proc_dpout(string s_org, DataSet ds_dpout, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_dpout.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_DP_OUT";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_dpout.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_dp", OracleType.Char, 20);
                command.Parameters["sp_dp"].Value = ds_dpout.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("sp_line_no", OracleType.Int32);
                command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_dpout.Tables[0].Rows[i]["dp_line_no"].ToString().Trim());
                command.Parameters.Add("sp_batch", OracleType.Char, 12);
                command.Parameters["sp_batch"].Value = ds_dpout.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_dpout.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_dpout.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_dpout.Tables[0].Rows[i]["con_qty"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //委外入库确认的存储过程
    [WebMethod]
    public string oracle_exec_proc_dpin(string s_org, DataSet ds_dpuse, DataSet ds_dpin, string s_user)
    {
        string str_lot,str_lotls,str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////委外用料的存储过程
            for (int i = 0; i < ds_dpuse.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_DP_USE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_dpuse.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_in", OracleType.Char, 20);
                command.Parameters["sp_in"].Value = ds_dpuse.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("sp_dp", OracleType.Char, 20);
                command.Parameters["sp_dp"].Value = ds_dpuse.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_dpuse.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                command.Parameters["sp_pack"].Value = ds_dpuse.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_dpuse.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_dpuse.Tables[0].Rows[i]["use_qty"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }

            /////委外入库的存储过程
            str_lot = "";
            for (int i = 0; i < ds_dpin.Tables[0].Rows.Count; i++)
            {
                command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_DP_INPUT";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_dpin.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_in", OracleType.Char, 20);
                command.Parameters["sp_in"].Value = ds_dpin.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_dpin.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_dpin.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_dpin.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                command.Parameters["sp_pack"].Value = ds_dpin.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("sp_qty_s", OracleType.Number, 16);
                command.Parameters["sp_qty_s"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("sp_cubage", OracleType.Number, 10);
                command.Parameters["sp_cubage"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_cubage"].ToString().Trim());
                command.Parameters.Add("sp_gross", OracleType.Number, 10);
                command.Parameters["sp_gross"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_gross_weight"].ToString().Trim());
                command.Parameters.Add("sp_net", OracleType.Number, 10);
                command.Parameters["sp_net"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_net_weight"].ToString().Trim());
                //处理批次属性 
                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";"+ str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                str_lotls = ds_dpin.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim();
                if (str_lotls == "") str_lotls = "tmp";
                str_lot = str_lot + ";" + str_lotls;

                command.Parameters.Add("sp_lot", OracleType.VarChar, 300);
                command.Parameters["sp_lot"].Value = str_lot;
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //卷钢开卷的存储过程
    [WebMethod]
    public string oracle_exec_proc_coiling(string s_org, DataSet ds_dpuse, DataSet ds_dpin, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////委外用料的存储过程
            for (int i = 0; i < ds_dpuse.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_DP_USE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_dpuse.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_in", OracleType.Char, 20);
                command.Parameters["sp_in"].Value = ds_dpuse.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("sp_dp", OracleType.Char, 20);
                command.Parameters["sp_dp"].Value = ds_dpuse.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_dpuse.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                command.Parameters["sp_pack"].Value = ds_dpuse.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_dpuse.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_dpuse.Tables[0].Rows[i]["use_qty"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }

            /////委外入库的存储过程
            for (int i = 0; i < ds_dpin.Tables[0].Rows.Count; i++)
            {
                command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_DP_COILING";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_dpin.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_in", OracleType.Char, 20);
                command.Parameters["sp_in"].Value = ds_dpin.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_dpin.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_dpin.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_dpin.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                command.Parameters["sp_pack"].Value = ds_dpin.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("sp_qty_s", OracleType.Number, 16);
                command.Parameters["sp_qty_s"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("sp_cubage", OracleType.Number, 10);
                command.Parameters["sp_cubage"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_cubage"].ToString().Trim());
                command.Parameters.Add("sp_gross", OracleType.Number, 10);
                command.Parameters["sp_gross"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_gross_weight"].ToString().Trim());
                command.Parameters.Add("sp_net", OracleType.Number, 10);
                command.Parameters["sp_net"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_net_weight"].ToString().Trim());
                command.Parameters.Add("sp_lot3", OracleType.VarChar, 20);
                command.Parameters["sp_lot3"].Value = ds_dpin.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim();
                command.Parameters.Add("sp_lot5", OracleType.VarChar, 20);
                command.Parameters["sp_lot5"].Value = ds_dpin.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                command.Parameters.Add("sp_coil_left", OracleType.Number, 10);
                command.Parameters["sp_coil_left"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["coil_left"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //委外计划入库确认的存储过程
    [WebMethod]
    public string oracle_exec_proc_plandpin(string s_org, DataSet ds_dpuse, DataSet ds_dpin, string strsql, string s_consignor, string s_in_no, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = strsql;
            dbCenter.updatedatabaser(command, ds_dpin);
            /////委外用料的存储过程
            for (int i = 0; i < ds_dpuse.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_DP_USE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_dpuse.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_in", OracleType.Char, 20);
                command.Parameters["sp_in"].Value = ds_dpuse.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("sp_dp", OracleType.Char, 20);
                command.Parameters["sp_dp"].Value = ds_dpuse.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_dpuse.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                command.Parameters["sp_pack"].Value = ds_dpuse.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_dpuse.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_dpuse.Tables[0].Rows[i]["use_qty"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
            command.Parameters.Clear();
            /////委外入库的存储过程
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_ORL_DP_PLANIN";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_in", OracleType.Char, 20);
            command.Parameters["sp_in"].Value = s_in_no;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 256);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //委外出库冲单的存储过程
    [WebMethod]
    public string oracle_exec_proc_dpredbill(string s_org, string s_consignor, string s_no,string s_ori_no, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_DP_REDBILLOUT");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_dp", OracleType.Char, 20);
            command.Parameters["sp_dp"].Value = s_no;
            command.Parameters.Add("sp_ori_dp", OracleType.Char, 20);
            command.Parameters["sp_ori_dp"].Value = s_ori_no;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 256);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }


    //委外入库冲单的存储过程
    [WebMethod]
    public string oracle_exec_proc_inredbill(string s_org, string s_consignor, string s_in, string s_ori_in, string s_user)
    {
        OracleCommand command;
        command = new OracleCommand(g_usespace + ".SP_ORL_DP_REDBILLIN");
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_in", OracleType.Char, 20);
            command.Parameters["sp_in"].Value = s_in;
            command.Parameters.Add("sp_ori_in", OracleType.Char, 20);
            command.Parameters["sp_ori_in"].Value = s_ori_in;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 256);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return command.Parameters["sp_out"].Value.ToString().Trim();
    }

    //质检确认存储过程
    [WebMethod]
    public string oracle_exec_proc_qcconfirm(DataSet ds_qcconfirm,string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_QC_CONFIRM";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_asnno", OracleType.Char, 20);
                command.Parameters["sp_asnno"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("sp_lineno", OracleType.Int32);
                command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("sp_recno", OracleType.Int32);
                command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty_m", OracleType.Number, 16);
                command.Parameters["sp_qty_m"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("sp_qty_s", OracleType.Number, 16);
                command.Parameters["sp_qty_s"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("sp_cubage", OracleType.Number, 10);
                command.Parameters["sp_cubage"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_cubage"].ToString().Trim());
                command.Parameters.Add("sp_gross", OracleType.Number, 10);
                command.Parameters["sp_gross"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_gross_weight"].ToString().Trim());
                command.Parameters.Add("sp_net", OracleType.Number, 10);
                command.Parameters["sp_net"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_net_weight"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_memo", OracleType.VarChar, 200);
                command.Parameters["sp_memo"].Value = ds_qcconfirm.Tables[0].Rows[i]["memo"].ToString().Trim();
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //质检确认存储过程
    [WebMethod]
    public string oracle_exec_proc_qcconfirm_new(DataSet ds_qcconfirm, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_QC_CONFIRM_NEW";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_asnno", OracleType.Char, 20);
                command.Parameters["sp_asnno"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("sp_lineno", OracleType.Int32);
                command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("sp_recno", OracleType.Int32);
                command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty_m", OracleType.Number, 16);
                command.Parameters["sp_qty_m"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("sp_qty_s", OracleType.Number, 16);
                command.Parameters["sp_qty_s"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("sp_cubage", OracleType.Number, 10);
                command.Parameters["sp_cubage"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_cubage"].ToString().Trim());
                command.Parameters.Add("sp_gross", OracleType.Number, 10);
                command.Parameters["sp_gross"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_gross_weight"].ToString().Trim());
                command.Parameters.Add("sp_net", OracleType.Number, 10);
                command.Parameters["sp_net"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_net_weight"].ToString().Trim());
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_memo", OracleType.VarChar, 200);
                command.Parameters["sp_memo"].Value = ds_qcconfirm.Tables[0].Rows[i]["memo"].ToString().Trim();
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //质检上架计算的存储过程
    [WebMethod]
    public string oracle_exec_proc_qcputaway(DataSet ds_qcconfirm,string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_QC_PUTAWAY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_asn", OracleType.Char, 20);
                command.Parameters["sp_asn"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("sp_lineno", OracleType.Int32);
                command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("sp_recno", OracleType.Int32);
                command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_qty", OracleType.Number, 16);
                command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_qcconfirm.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_pack", OracleType.Char, 30);
                command.Parameters["sp_pack"].Value = ds_qcconfirm.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_loc", OracleType.VarChar, 256);
                command.Parameters["sp_loc"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_loc"].Value.ToString().Trim().ToUpper().Substring(0, 3) == "ERR")
                {
                    str_ls_middle = command.Parameters["sp_loc"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //质检上架确认的存储过程
    [WebMethod]
    public string oracle_exec_proc_qcpaconfirm(DataSet ds_qcconfirm, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_QCPA_CONFIRM";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_asn", OracleType.Char, 20);
                command.Parameters["sp_asn"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("sp_lineno", OracleType.Int32);
                command.Parameters["sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("sp_recno", OracleType.Int32);
                command.Parameters["sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("sp_loc", OracleType.Char, 20);
                command.Parameters["sp_loc"].Value = ds_qcconfirm.Tables[0].Rows[i]["fact_location"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_method", OracleType.Char, 1);
                command.Parameters["sp_method"].Value = "1";
                command.Parameters.Add("sp_out", OracleType.VarChar, 256);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //移库指令新增
    [WebMethod]
    public string oracle_exec_proc_moveadd_header(string s_org, string s_consignor, string s_moveno, DataSet ds_move, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_move.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_MOVE_ADD_ORDER";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_consignor", OracleType.Char, 15);
                command.Parameters["sp_consignor"].Value = s_consignor;
                command.Parameters.Add("sp_moveno", OracleType.Char, 20);
                command.Parameters["sp_moveno"].Value = s_moveno;
                command.Parameters.Add("sp_lineon", OracleType.Int32);
                command.Parameters["sp_lineon"].Value = System.Convert.ToInt32(ds_move.Tables[0].Rows[i]["sp_lineon"].ToString().Trim());
                command.Parameters.Add("sp_warehouseout", OracleType.Char, 5);
                command.Parameters["sp_warehouseout"].Value = ds_move.Tables[0].Rows[i]["sp_warehouseout"].ToString().Trim();
                command.Parameters.Add("sp_warehousein", OracleType.Char, 5);
                command.Parameters["sp_warehousein"].Value = ds_move.Tables[0].Rows[i]["sp_warehousein"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("sp_batch", OracleType.Char, 12);
                command.Parameters["sp_batch"].Value = ds_move.Tables[0].Rows[i]["sp_batch"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_move.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("sp_use_qty", OracleType.Number, 16);
                command.Parameters["sp_use_qty"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty"].ToString().Trim());
                command.Parameters.Add("sp_outloc", OracleType.Char, 20);
                command.Parameters["sp_outloc"].Value = ds_move.Tables[0].Rows[i]["sp_outloc"].ToString().Trim();
                command.Parameters.Add("sp_inloc", OracleType.Char, 20);
                command.Parameters["sp_inloc"].Value = ds_move.Tables[0].Rows[i]["sp_inloc"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //移库指令删除
    [WebMethod]
    public string oracle_exec_proc_movedel_header(string s_org, string s_consignor, string s_moveno, DataSet ds_move, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_move.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_MOVE_DELETE_ORDER";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_consignor", OracleType.Char, 15);
                command.Parameters["sp_consignor"].Value = s_consignor;
                command.Parameters.Add("sp_moveno", OracleType.Char, 20);
                command.Parameters["sp_moveno"].Value = s_moveno;
                command.Parameters.Add("sp_lineon", OracleType.Int32);
                command.Parameters["sp_lineon"].Value = System.Convert.ToInt32(ds_move.Tables[0].Rows[i]["sp_lineon"].ToString().Trim());
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("sp_in_pallet", OracleType.Char, 15);
                command.Parameters["sp_in_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_in_pallet"].ToString().Trim();
                command.Parameters.Add("sp_batch", OracleType.Char, 12);
                command.Parameters["sp_batch"].Value = ds_move.Tables[0].Rows[i]["sp_batch"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_move.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("sp_use_qty", OracleType.Number, 16);
                command.Parameters["sp_use_qty"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty"].ToString().Trim());
                command.Parameters.Add("sp_use_qty_s", OracleType.Number, 16);
                command.Parameters["sp_use_qty_s"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty_s"].ToString().Trim());
                command.Parameters.Add("sp_outloc", OracleType.Char, 20);
                command.Parameters["sp_outloc"].Value = ds_move.Tables[0].Rows[i]["sp_outloc"].ToString().Trim();
                command.Parameters.Add("sp_inloc", OracleType.Char, 20);
                command.Parameters["sp_inloc"].Value = ds_move.Tables[0].Rows[i]["sp_inloc"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //移库指令修改
    [WebMethod]
    public string oracle_exec_proc_movemodify_header(string s_org, string s_consignor, string s_moveno, DataSet ds_move, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_move.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_MOVE_MODIFY_ORDER";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = s_org;
                command.Parameters.Add("sp_consignor", OracleType.Char, 15);
                command.Parameters["sp_consignor"].Value = s_consignor;
                command.Parameters.Add("sp_moveno", OracleType.Char, 20);
                command.Parameters["sp_moveno"].Value = s_moveno;
                command.Parameters.Add("sp_lineon", OracleType.Int32);
                command.Parameters["sp_lineon"].Value = System.Convert.ToInt32(ds_move.Tables[0].Rows[i]["sp_lineon"].ToString().Trim());
                command.Parameters.Add("sp_warehousein", OracleType.Char, 5);
                command.Parameters["sp_warehousein"].Value = ds_move.Tables[0].Rows[i]["sp_warehousein"].ToString().Trim();
                command.Parameters.Add("sp_pallet", OracleType.Char, 15);
                command.Parameters["sp_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("sp_batch", OracleType.Char, 12);
                command.Parameters["sp_batch"].Value = ds_move.Tables[0].Rows[i]["sp_batch"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_move.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("sp_use_qty", OracleType.Number, 16);
                command.Parameters["sp_use_qty"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty"].ToString().Trim());
                command.Parameters.Add("sp_use_qty_s", OracleType.Number, 16);
                command.Parameters["sp_use_qty_s"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty_s"].ToString().Trim());
                command.Parameters.Add("sp_outloc", OracleType.Char, 20);
                command.Parameters["sp_outloc"].Value = ds_move.Tables[0].Rows[i]["sp_outloc"].ToString().Trim();
                command.Parameters.Add("sp_inloc", OracleType.Char, 20);
                command.Parameters["sp_inloc"].Value = ds_move.Tables[0].Rows[i]["sp_inloc"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //越库入库直接转快速出库
    [WebMethod]
    public string oracle_exec_proc_asntoso(string s_org, string s_consignor, string s_asnno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_ORL_ASNTOSO";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asno", OracleType.Char, 20);
            command.Parameters["sp_asno"].Value = s_asnno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //越库入库直接转快速出库
    [WebMethod]
    public string oracle_exec_proc_asntoso_new(string s_org, string s_consignor, string s_asnno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_ORL_ASNTOSO_NEW";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_asno", OracleType.Char, 20);
            command.Parameters["sp_asno"].Value = s_asnno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //越库快速出库确认直接转对方入库单
    [WebMethod]
    public string oracle_exec_proc_transfer_asn(DataSet ds_tk, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_tk.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_TRANSFER_ASN";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_tk.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_tk.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_tkno", OracleType.Char, 20);
                command.Parameters["sp_tkno"].Value = ds_tk.Tables[0].Rows[i]["tk_no"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    #endregion

    #region 修改包装信息
    [WebMethod]
    public string oracle_exec_proc_checkpack(DataSet ds_change_pack)
    {
        string str_ls_middle;
        int i_count;
        OracleCommand command;
        str_ls_middle = "";
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            i_count = 0;
            for (int i = 0; i < ds_change_pack.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_CHECK_PACK";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_change_pack.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_change_pack.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_change_pack.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_new_pack", OracleType.Char, 30);
                command.Parameters["sp_new_pack"].Value = ds_change_pack.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_out", OracleType.VarChar, 255);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim() + "/r/n";
                    i_count ++;
                    if (i_count > 20) //说明超过20个物料有问题,退出
                    {
                        break;
                    }
                }
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    [WebMethod]
    public string oracle_exec_proc_changepack(DataSet ds_change_pack, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        str_ls_middle = "";
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            for (int i = 0; i < ds_change_pack.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_ORL_CHANGE_PACK";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("sp_org", OracleType.Char, 15);
                command.Parameters["sp_org"].Value = ds_change_pack.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                command.Parameters["sp_csgor"].Value = ds_change_pack.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("sp_sku", OracleType.Char, 30);
                command.Parameters["sp_sku"].Value = ds_change_pack.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("sp_new_pack", OracleType.Char, 30);
                command.Parameters["sp_new_pack"].Value = ds_change_pack.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("sp_user", OracleType.Char, 10);
                command.Parameters["sp_user"].Value = s_user;
                command.Parameters.Add("sp_out", OracleType.VarChar, 255);
                command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                dbCenter.ExecuteNonQuery(command);
                if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                dbCenter.Commit();
            else
                dbCenter.Rollback();
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }
    #endregion

    //宜昌结算单
    [WebMethod]
    public string oracle_exec_proc_asn_checkfee(string s_org, string s_csgor, string s_asn_no,DateTime dt_cur_time, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        str_ls_middle = "";
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        try
        {
            dbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_ORL_ASN_CHECKFEE";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_csgor;
            command.Parameters.Add("sp_asn", OracleType.Char, 20);
            command.Parameters["sp_asn"].Value = s_asn_no;
            command.Parameters.Add("sp_cur_day", OracleType.DateTime);
            command.Parameters["sp_cur_day"].Value = dt_cur_time;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 255);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //上海江森转出库
    [WebMethod]
    public string oracle_pick_transfer_js(string s_org, string s_consignor, string s_so_no, string s_taxno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            command.CommandText = g_usespace + ".SP_ORL_PICK_TRANSFER_JS";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = s_org;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = s_consignor;
            command.Parameters.Add("sp_so", OracleType.Char, 20);
            command.Parameters["sp_so"].Value = s_so_no;
            command.Parameters.Add("sp_lotstr", OracleType.Char, 300);
            command.Parameters["sp_lotstr"].Value = s_taxno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally 
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //20150505川山甲新增功能web服务
    //调拨单表头删除
    [WebMethod]
    public string oracle_exec_proc_allot_headerdel(string str_inv, string str_consignor, string str_allotno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_ORL_ALLOT_DEL_HEADER";
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = str_inv;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = str_consignor;
            command.Parameters.Add("sp_allotno", OracleType.Char, 20);
            command.Parameters["sp_allotno"].Value = str_allotno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
            command.Parameters.Clear();

            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //调拨单明细删除
    [WebMethod]
    public string oracle_exec_proc_allot_detaildel(string str_inv, string str_consignor, string str_allotno, int i_lineno, string s_user)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_ORL_ALLOT_DEL_DETAIL";
            command.Parameters.Add("sp_org", OracleType.Char, 15);
            command.Parameters["sp_org"].Value = str_inv;
            command.Parameters.Add("sp_csgor", OracleType.Char, 15);
            command.Parameters["sp_csgor"].Value = str_consignor;
            command.Parameters.Add("sp_allotno", OracleType.Char, 20);
            command.Parameters["sp_allotno"].Value = str_allotno;
            command.Parameters.Add("sp_line_no", OracleType.Int32);
            command.Parameters["sp_line_no"].Value = i_lineno;
            command.Parameters.Add("sp_user", OracleType.Char, 10);
            command.Parameters["sp_user"].Value = s_user;
            command.Parameters.Add("sp_out", OracleType.VarChar, 100);
            command.Parameters["sp_out"].Direction = ParameterDirection.Output;
            dbCenter.ExecuteNonQuery(command);
            if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
            }
            command.Parameters.Clear();

            if (str_ls_middle.Trim() == "")
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }   
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //川山甲调拨确认
    [WebMethod]
    public string oracle_exec_proc_allot_confirm(DataSet ds_allot, string str_flag, string s_user)
    {
        string s_str;
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        s_str = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_allot.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_allot.Tables[0].Rows.Count; i++)
                {   
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_ORL_ALLOT_CONFIRM";
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_allot.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_allot.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_allotno", OracleType.Char, 20);
                    command.Parameters["sp_allotno"].Value = ds_allot.Tables[0].Rows[i]["allotment_no"].ToString().Trim();
                    command.Parameters.Add("sp_line_no", OracleType.Int32);
                    command.Parameters["sp_line_no"].Value = System.Convert.ToInt32(ds_allot.Tables[0].Rows[i]["allotment_line_no"].ToString().Trim());
                    command.Parameters.Add("sp_qty", OracleType.Number, 16);
                    command.Parameters["sp_qty"].Value = System.Convert.ToDecimal(ds_allot.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                    command.Parameters.Add("sp_flag", OracleType.Char, 1);
                    command.Parameters["sp_flag"].Value = str_flag;
                    command.Parameters.Add("sp_user", OracleType.Char, 10);
                    command.Parameters["sp_user"].Value = s_user;
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                s_str = "update " + g_usespace + ".Inv_Allotment_Header set confirm_day = sysdate,confirmer = '" + s_user + "',main_dist = 'C',allotment_status = '2' " +
                       "where inv_org = '" + ds_allot.Tables[0].Rows[0]["inv_org"].ToString().Trim() + "' and consignor = '" + ds_allot.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and allotment_no = '" + ds_allot.Tables[0].Rows[0]["allotment_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                command.CommandType = CommandType.Text;
                dbCenter.ExecuteNonQuery(command);

                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }



    //////////////////////////////////// ORACLE数据库结束/////////////////////////////////////////////////////////


//////////////////////////////////// SQLCERVER数据库/////////////////////////////////////////////////////////
    //得到服务器的IP地址
    [WebMethod]
    public string Sql_get_ip(string str_inv, int i_no)
    {
        string str_mac, str_ip, str_return;
        SqlCommand command;
        DataSet ds;
        command = new SqlCommand();
        ds = new DataSet();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            str_mac = "select rtrim(ltrim(id_data)) from " + g_usespace + ".sys_parameter where inv_org = '" + str_inv + "' and id = " + i_no.ToString().Trim();
            command.CommandText = str_mac;
            ds = SqldbCenter.ExecuteQuery(command);
            if (ds.Tables[0].Rows.Count > 0) //说明找到 
            {
                str_mac = ds.Tables[0].Rows[0][0].ToString().Trim();
                str_ip = "";
                IPAddress[] localIPs;
                localIPs = Dns.GetHostAddresses(str_mac);
                StringCollection IpCollection = new StringCollection();
                foreach (IPAddress ip in localIPs)
                {
                    //根据AddressFamily判断是否为ipv4,如果是InterNetWork则为ipv6
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        str_ip = ip.ToString().Trim();
                        break;
                    }
                }
                if (str_ip == "")
                {
                    str_return = "";
                }
                else
                {
                    str_return = str_mac.Trim() + str_ip.Trim();
                }
            }
            else //没有找到 
            {
                str_return = "";
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_return;
    }


    //提取系统登录信息
    [WebMethod]
    public DataSet Sql_get_logininfor(string strsql)
    {
        SqlCommand command;
        DataSet ds;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            ds = SqldbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return ds;
    }

    /// <summary>
    /// 返回第一行第一列
    /// </summary>
    /// <param name="strsql"></param>
    /// <returns></returns>
    [WebMethod]
    public string Sql_exec_selectstring(string strsql)
    {
        SqlCommand command;
        DataSet ds;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            ds = SqldbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        if (ds.Tables[0].Rows.Count > 0)
            return ds.Tables[0].Rows[0][0].ToString().Trim();
        else
            return "";
    }

    //执行通用select语句返回整型
    [WebMethod]
    public Int32 Sql_exec_selectint(string strsql)
    {
        SqlCommand command;
        DataSet ds;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            ds = SqldbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        if (ds.Tables[0].Rows.Count > 0)
            return System.Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString().Trim());
        else
            return 0;
    }

    //执行通用select语句语句返回数据集
    [WebMethod]
    public DataSet Sql_exec_selectsql(string strsql)
    {
        SqlCommand command;
        DataSet ds;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            ds = SqldbCenter.ExecuteQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return ds;
    }

    //执行通用command语句
    [WebMethod]
    public void Sql_exec_commandsql(string strsql)
    {
        SqlCommand command;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    /// <summary>
    //执行通用command语句返回影响行数
    /// </summary>
    /// <param name="strsql"></param>
    /// <returns></returns>
    [WebMethod]
    public int Sql_exec_command(string strsql)
    {
        int resultCnt = 0;
        SqlCommand command;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            resultCnt= SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return resultCnt;
    }


    //批量更新数据库
    [WebMethod]
    public void Sql_refresh_db(DataSet dtst, string strsql)
    {
        SqlCommand command;
        command = new SqlCommand(strsql);
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.updatedatabaser(command, dtst);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //批量更新数据库再加一条sql语句
    [WebMethod]
    public void Sql_insert_dataset(string str_insert, DataSet dtst, string strsql)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try 
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = str_insert;
            SqldbCenter.ExecuteNonQuery(command);
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //得到相应的单据号
    [WebMethod]
    public Int32 Sql_get_accountno(string s_org, string straccount)
    {
        string s_str;
        Int32 r_int;
        SqlCommand command;
        DataSet ds;
        command = new SqlCommand();
        ds = new DataSet();
        straccount = straccount.ToUpper();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //先锁账号表
            s_str = "update " + g_usespace + ".mst_account set page_no = page_no where inv_org = '"+s_org+"' and upper(bill_id) = '" + straccount + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //得到相应的帐号
            s_str = "select page_no from " + g_usespace + ".mst_account where inv_org = '" + s_org + "' and upper(bill_id) = '" + straccount + "'";
            command.CommandText = s_str;
            ds = SqldbCenter.ExecuteQuery(command);
            if (ds.Tables[0].Rows.Count > 0) //说明找到
            {
                r_int = System.Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString().Trim());
                r_int = r_int + 1;
            }
            else //没有找到
            {
                r_int = 0;
            }
            //更新帐号表
            s_str = "update " + g_usespace + ".mst_account set page_no = page_no + 1 where inv_org = '" + s_org + "' and upper(bill_id) = '" + straccount + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command); 
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return r_int;
    }

    //执行多条sql更新或者插入的语句
    [WebMethod]
    public void Sql_exec_mutilsql(string[] str_array)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < str_array.Length; i++)
            {
                if (str_array[i].ToString().Trim() != "")
                {
                    command.CommandText = str_array[i].ToString().Trim();
                    SqldbCenter.ExecuteNonQuery(command);
                }
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    #region 订单管理的函数

    //订单计划做成 
    [WebMethod]
    public string Sql_make_plan_asnno(DataSet ds_asn, string str_userid)
    {
        DataView dv_asn;
        DataTable dt_asn;
        string ls_middle, str_supply, str_supply_old, str_asnno, str_command;
        string str_first_no;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        ls_middle = "";
        str_supply = "";
        str_supply_old = "";
        str_asnno = "";
        str_first_no = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            dv_asn = ds_asn.Tables[0].DefaultView;
            dv_asn.Sort = "supply,asn_line_no";
            dt_asn = dv_asn.ToTable();
            if (dt_asn.Rows.Count > 0)  //有数据进行单据号的拆分
            {
                for (int i = 0; i < dt_asn.Rows.Count; i++)
                {
                    str_supply = dt_asn.Rows[i]["supply"].ToString().Trim();
                    if (str_supply.Trim() != str_supply_old.Trim()) //说明不相等,插入表头
                    {
                        //得到单据号
                        str_asnno = "AN" + oracle_get_accountno(dt_asn.Rows[i]["inv_org"].ToString().Trim(), "ASN_NO").ToString("00000000");
                        //插入表头
                        if (i == 0)  //说明是第一个
                        {
                            str_first_no = str_asnno;
                        }
                        str_command = "insert into " + g_usespace + ".asn_order_header(	inv_org,	consignor,	asn_no,		customer_order_no," +
                                                                                   "eas_order,	contract_no,	order_day,	asn_type," +
                                                                                   "supply,		supply_country,	supply_address,	supply_city," +
                                                                                   "supply_province,	supply_postalcode,	supply_phone,	carrier," +
                                                                                   "carrier_address,	carrier_postalcode,	carrier_phone,	ship_no," +
                                                                                   "fly_no,		vehicle_no,	load_place,	discharge_place," +
                                                                                   "deliver_place,	in_tax,		out_tax,	arrive_plan_day," +
                                                                                   "arrive_deadline,	arrive_day,	asn_status,	arrive_status," +
                                                                                   "colse_day,	colser,		book_status," +
                                                                                   "door,		booker,		buyer,		from_inv_org," +
                                                                                   "so_no,		standby_1,	standby_2,	standby_3," +
                                                                                   "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                   "standby_8,	standby_9,	applier,	ld_dist," +
                                                                                   "memo2,		memo,        main_dist,	made_time,	maker) " +
                                                                           "select a.inv_org,	a.consignor,	'" + str_asnno + "',customer_order_no," +
                                                                                   "'',	'', convert(char(10),getdate(),102),	'0'," +
                                                                                   "a.supply,		b.country,	b.business_address,	b.city," +
                                                                                   "b.province,	b.postalcode,	b.telephone,	''," +
                                                                                   "'',	'',	'',	''," +
                                                                                   "'',		'',	'',	''," +
                                                                                   "'',	17,		17,	convert(char(10),getdate(),102)," +
                                                                                   "'',	'',	'0',	'0'," +
                                                                                   "'',	'',		'0'," +
                                                                                   "'',		'',		buyer,		''," +
                                                                                   "'',		'',	'0',	''," +
                                                                                   "1,	0,	'',	''," +
                                                                                   "'',	'',	applier,	'0'," +
                                                                                   "'',		'',       'A',	getdate(),	'" + str_userid + "' " +
                                                                       "from " + g_usespace + ".asn_order_make a," + g_usespace + ".mst_customer b " +
                                                                       "where a.inv_org = b.inv_org and rtrim(ltrim(a.supply)) = rtrim(ltrim(b.consignor)) and b.supply_flag = '1' and a.happen_day = '" + dt_asn.Rows[i]["happen_day"].ToString().Trim() + "'" +
                                                                       " and a.inv_org = '" + dt_asn.Rows[i]["inv_org"].ToString().Trim() + "' and a.consignor = '" + dt_asn.Rows[i]["consignor"].ToString().Trim() + "' and a.asn_line_no = " + dt_asn.Rows[i]["asn_line_no"].ToString().Trim();
                        command.CommandText = str_command;
                        SqldbCenter.ExecuteNonQuery(command);
                        str_supply_old = str_supply;
                    }
                    //插入明细
                    str_command = "insert into " + g_usespace + ".asn_order_detail(	inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                   "eas_order,	order_line_no,	sku,		pack_code," +
                                                                                   "order_qty_m,	order_qty_s,	present_qty_m,	present_qty_s," +
                                                                                   "order_price,	order_unit,	cubage,		gross_weight," +
                                                                                   "net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s," +
                                                                                   "receive_present_qty_m,	receive_present_qty_s,	main_sub_flag,	convert_modulus," +
                                                                                   "receive_day,	receive_status,	lot_attribute1,	lot_attribute2," +
                                                                                   "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                                   "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                                   "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                   "lot_attribute15,	standby_1,	standby_2,	standby_3," +
                                                                                   "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                   "tax_dist,	doc_link,	memo,		main_dist,made_time,	maker) " +
                                                                           "select inv_org,	consignor,	'" + str_asnno + "',		asn_line_no," +
                                                                                   "'',	0,	sku,		pack_code," +
                                                                                   "order_qty_m,	order_qty_s,	0,	0," +
                                                                                   "order_price,	order_unit,	cubage,		gross_weight," +
                                                                                   "net_weight,	shelflife_day,	0,	0," +
                                                                                   "0,	0,	main_sub_flag,	convert_modulus," +
                                                                                   "'',	'0',	lot_attribute1,	lot_attribute2," +
                                                                                   "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                                   "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                                   "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                   "lot_attribute15,	'0',	'',	''," +
                                                                                   "'',	'',	0,	0," +
                                                                                   "lot_attribute3,	'',	memo,		'A' ,getdate(),	'" + str_userid + "' " +
                                                                       "from " + g_usespace + ".asn_order_make " +
                                                                       "where happen_day = '" + dt_asn.Rows[i]["happen_day"].ToString().Trim() + "'" +
                                                                       " and inv_org = '" + dt_asn.Rows[i]["inv_org"].ToString().Trim() + "' and consignor = '" + dt_asn.Rows[i]["consignor"].ToString().Trim() + "' and asn_line_no = " + dt_asn.Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = str_command;
                    SqldbCenter.ExecuteNonQuery(command);
                    //修改状态是做成
                    str_command = "update " + g_usespace + ".asn_order_make set receive_status = '3',update_time = getdate(),updater = '" + str_userid + "' where happen_day = '" + dt_asn.Rows[i]["happen_day"].ToString().Trim() + "'" +
                                                                       " and inv_org = '" + dt_asn.Rows[i]["inv_org"].ToString().Trim() + "' and consignor = '" + dt_asn.Rows[i]["consignor"].ToString().Trim() + "' and asn_line_no = " + dt_asn.Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = str_command;
                    SqldbCenter.ExecuteNonQuery(command);
                } 
            }
            SqldbCenter.Commit();
            ls_middle = str_first_no;
        }
        catch (System.Exception ee)
        {
            ls_middle = ee.Message.ToString().Trim();
            SqldbCenter.Rollback();
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return ls_middle.Trim();
    }

    //删除整张订单信息，存在表头和明细，所以要在一个事物里面删除
    [WebMethod]
    public void Sql_del_asnno(string s_org, string str_sto, string str_asnh)
    {
        string s_str;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //先删除明细
            s_str = "delete " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and asn_no ='" + str_asnh + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //在删除表头
            s_str = "delete " + g_usespace + ".asn_order_header where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and asn_no ='" + str_asnh + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //拆分订单
    [WebMethod]
    public void Sql_exec_proc_bom(string s_org, string s_consignor, string s_asn_no, string s_sku, decimal d_ordm, decimal d_fordm, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace+".SP_SQL_SPLIT_BOM");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor",SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_asn_no", SqlDbType.Char, 20);
            command.Parameters["@sp_asn_no"].Value = s_asn_no;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_ordm", SqlDbType.Decimal);
            command.Parameters["@sp_ordm"].Precision = (byte)16;
            command.Parameters["@sp_ordm"].Scale = (byte)4;
            command.Parameters["@sp_ordm"].Value = d_ordm;
            command.Parameters.Add("@sp_fordm", SqlDbType.Decimal);
            command.Parameters["@sp_fordm"].Precision = (byte)16;
            command.Parameters["@sp_fordm"].Scale = (byte)4;
  //          command.Parameters["sp_fordm"].Direction = ParameterDirection.Output               
            command.Parameters["@sp_fordm"].Value = d_fordm;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //拆板存储过程
    [WebMethod]
    public void Sql_exec_proc_split(string s_org, string s_consignor, string s_asn_no, int i_asnno,int i_recno, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PALLET_SPLIT");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.VarChar, 100);
            command.Parameters["@sp_flag"].Direction = ParameterDirection.Output;
            command.Parameters["@sp_flag"].Value = "";
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //新拆板存储过程
    [WebMethod]
    public string Sql_exec_proc_split_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PALLET_SPLIT_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //新重新拆板存储过程
    [WebMethod]
    public string Sql_exec_proc_resplit_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, int i_qty, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_RESPLIT_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try 
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_qty", SqlDbType.Int);  
            command.Parameters["@sp_qty"].Value = i_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //重新拆板存储过程
    [WebMethod]
    public void Sql_exec_proc_resplit(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, int i_qty, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_RESPLIT");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_qty", SqlDbType.Int);
            command.Parameters["@sp_qty"].Value = i_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.VarChar, 100);
            command.Parameters["@sp_flag"].Direction = ParameterDirection.Output;
            command.Parameters["@sp_flag"].Value = "";
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //PC机上的收货确认新的流程
    [WebMethod]
    public string Sql_confirm_asnno_new(string s_org, DataSet ds_asn, int i_receive_count, string str_userid)
    {
        int i_rec_count;
        string ls_middle, s_str, str_lot;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (i_receive_count <= 0)
            {
                //得到收货次数
                s_str = "select isnull(max(to_number(standby_5)),0) + 1 from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no = '" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
                i_rec_count = Sql_exec_selectint(s_str);
            }
            else
            {
                i_rec_count = i_receive_count;
            }
            //调用存储过程进行收货
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                if (System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) > 0) //说明有收货数
                {
                    //设置15个批次属性
                    str_lot = ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + ";" +
                              ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + ";" +
                              ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + ";" +
                              ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + ";" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + ";";
                    //开始调用存储过程
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_RECEIVE_NEW";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = s_org;
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_qtym", SqlDbType.Decimal);
                    command.Parameters["@sp_qtym"].Precision = (byte)16;
                    command.Parameters["@sp_qtym"].Scale = (byte)4;
                    command.Parameters["@sp_qtym"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim());
                    command.Parameters.Add("@sp_qtys", SqlDbType.Decimal);
                    command.Parameters["@sp_qtys"].Precision = (byte)16;
                    command.Parameters["@sp_qtys"].Scale = (byte)4;
                    command.Parameters["@sp_qtys"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim());
                    command.Parameters.Add("@sp_fqtym", SqlDbType.Decimal);
                    command.Parameters["@sp_fqtym"].Precision = (byte)16;
                    command.Parameters["@sp_fqtym"].Scale = (byte)4;
                    command.Parameters["@sp_fqtym"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim());
                    command.Parameters.Add("@sp_fqtys", SqlDbType.Decimal);
                    command.Parameters["@sp_fqtys"].Precision = (byte)16;
                    command.Parameters["@sp_fqtys"].Scale = (byte)4;
                    command.Parameters["@sp_fqtys"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim());
                    command.Parameters.Add("@sp_cubage", SqlDbType.Decimal);
                    command.Parameters["@sp_cubage"].Precision = (byte)10;
                    command.Parameters["@sp_cubage"].Scale = (byte)4;
                    command.Parameters["@sp_cubage"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim());
                    command.Parameters.Add("@sp_gross", SqlDbType.Decimal);
                    command.Parameters["@sp_gross"].Precision = (byte)10;
                    command.Parameters["@sp_gross"].Scale = (byte)4;
                    command.Parameters["@sp_gross"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim());
                    command.Parameters.Add("@sp_net", SqlDbType.Decimal);
                    command.Parameters["@sp_net"].Precision = (byte)10;
                    command.Parameters["@sp_net"].Scale = (byte)4;
                    command.Parameters["@sp_net"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim());
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_asn.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lotstr", SqlDbType.VarChar, 300);
                    command.Parameters["@sp_lotstr"].Value = str_lot;
                    command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 255); 
                    command.Parameters["@sp_memo"].Value = ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim();
                    command.Parameters.Add("@sp_rec_count", SqlDbType.Int);
                    command.Parameters["@sp_rec_count"].Value = i_rec_count;
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = str_userid;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "0")
                    {
                        ls_middle = ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (ls_middle.Trim() != "")
            {
                SqldbCenter.Rollback();
            }
            else
            {
                SqldbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return ls_middle.Trim();
    }

    //PC上收货确认
    [WebMethod]
    public string Sql_confirm_asnno(string s_org, DataSet ds_asn,string str_userid)
    { 
        string s_str, s_pallet_flag, s_pa_flag, s_sugg_loc, s_asntype, s_taxdist;
        string str_rec_no, s_type, ls_middle; //收货的次数 
        int i_rec_no;
        DataSet ds_sku;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //得到是否上架计算的参数
            s_str = "select isnull(id_data,'0') from " + g_usespace + ".sys_parameter where inv_org = '" + s_org + "' and id = 8102"; 
            s_pa_flag = Sql_exec_selectstring(s_str);
            s_str = "select isnull(max(convert(int,standby_5)),0) + 1 from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no = '" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
            str_rec_no = Sql_exec_selectstring(s_str);
            //得到单据类型
            s_str = "select asn_type from " + g_usespace + ".asn_order_header where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no = '" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
            s_type = Sql_exec_selectstring(s_str);
            //循环进行收货确认
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                if (System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) != 0) //说明有收货数
                {
                    //得到最大行号
                    s_str = "select isnull(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '"+s_org+"' and consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' " +
                            "and asn_no ='" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "' and asn_line_no =" + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = s_str;
                    i_rec_no = SqldbCenter.ExecuteScalar(command);
                    i_rec_no = i_rec_no + 1;

                    //判断该商品是托盘管理还是非托盘管理
                    s_str = "select isnull(a.pallet_flag,'0') pallet_flag,b.asn_type,c.tax_dist from " + g_usespace + ".mst_sku a," + g_usespace + ".asn_order_header b," + g_usespace + ".asn_order_detail c where a.inv_org = '" + s_org + "' and a.consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() +
                           "' and a.sku = '" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and a.inv_org = c.inv_org and a.consignor = c.consignor and a.sku = c.sku and c.inv_org = b.inv_org and c.consignor = b.consignor and c.asn_no = b.asn_no";
                    command.CommandText = s_str;
                    ds_sku = SqldbCenter.ExecuteQuery(command);
                    s_asntype = ds_sku.Tables[0].Rows[0]["asn_type"].ToString().Trim();
                    s_taxdist = ds_sku.Tables[0].Rows[0]["tax_dist"].ToString().Trim();
                    s_pallet_flag = ds_sku.Tables[0].Rows[0]["pallet_flag"].ToString().Trim();
                    //插入收货数据
                    s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                                    "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                                    "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                    "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                    "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                            "values('"+s_org+"','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + "," +
                            System.Convert.ToString(i_rec_no) + ",'" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" +
                            ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + "," +
                            ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim() + "," +
                            ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" + DateTime.Now.ToString("yyyy.MM.dd") + "',";
                    if (s_pallet_flag == "0")  //非托盘管理，直接插入拆板，并且状态是拆板
                        s_str = s_str + "'1',";
                    else  //托盘，不拆板，状态是收货确认
                        s_str = s_str + "'0',";
                    s_str = s_str + "'" + ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                        ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                        ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                        ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "','','','','','" + str_rec_no + "',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',getdate(),'" + str_userid + "')";
                    command.CommandText = s_str;
                    SqldbCenter.ExecuteNonQuery(command);
                    //如果是非托盘，插入拆版数据
                    if (s_pallet_flag == "0")
                    {
                        s_str = "insert into " + g_usespace + ".asn_pallet_split(inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,	pallet_no,	sku,		pack_code,	order_price,order_unit," +
                                                                "pallet_qty_m,	pallet_qty_s,	main_sub_flag,	convert_modulus,	shelflife_day, cubage,		gross_weight," +
                                                                "net_weight,	spliter,	split_status,	split_date,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                                "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                                "lot_attribute13,	lot_attribute14,	lot_attribute15,	standby_1,	standby_2,	standby_3,	standby_4,	standby_5," +
                                                                "standby_6,	standby_7,	memo,		main_dist,	made_time,	maker)" +
                                "values('" + s_org + "','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + "," +
                                System.Convert.ToString(i_rec_no) + ",'000000000000000','" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "'," +
                                System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim())) + "," +
                                System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim())) + ",'" +
                                ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + ",'" +
                                str_userid + "','0','" + DateTime.Now.ToString("yyyy.MM.dd") + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "','','','','','" + str_rec_no + "',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',getdate(),'" + str_userid + "')";
                        command.CommandText = s_str;
                        SqldbCenter.ExecuteNonQuery(command);
                    }
                    //如果是非托盘管理并且不需要上架计算,直接插入上架计算表
                    //2012.05.25针对鑫马非托盘管理,收货后是否直接插入上架计算表
                    if (s_pa_flag == "1") //直接插入上架计算表
                    {
                        //得到相应商品的有库存的库位
                        //s_asntype, s_taxdist;location_flag
                        s_str = "select isnull(max(a.location_code),'') from " + g_usespace + ".inv_sku_location a," + g_usespace 
                            + ".mst_location b where a.inv_org = '" + s_org + "' and a.consignor = '" + 
                            ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and a.sku = '" + 
                            ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and a.pack_code = '" +
                                ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() +
                                "' and a.inv_org = b.inv_org and a.location_code = b.location_code and b.lock_flag = '0'";
                        if (s_asntype == "3") //寄售
                        {
                            s_str = s_str + " and b.location_flag = '3'";
                        }
                        else
                        {
                            s_str = s_str + " and b.location_flag = '0'";
                        }
                        if (s_taxdist.Trim() == "保税") //保税区分
                        { 
                            s_str = s_str + " and b.standby_flag1 = '1'";
                        }
                        else
                        {
                            s_str = s_str + " and b.standby_flag1 = '0'";
                        }
                        s_sugg_loc = Sql_exec_selectstring(s_str);
                        s_str = "insert into " + g_usespace + ".asn_putaway(inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                           "receive_line_no,	pallet_no,	sku,		pack_code," +
                                                                           "order_price,	order_unit,	putaway_qty_m,	putaway_qty_s," +
                                                                           "main_sub_flag,	convert_modulus,	suggest_location,	shelflife_day," +
                                                                           "cubage,		gross_weight,	net_weight,	putaway_status," +
                                                                           "fact_location,	putawayer,	putaway_flag,	putaway_date," +
                                                                           "print_flag,	printer,	label_flag," +
                                                                           "labeler,	lot_attribute1,	lot_attribute2," +
                                                                           "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                           "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                           "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                           "lot_attribute15,	standby_1,	standby_2,	standby_3," +
                                                                           "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                           "memo,		main_dist,	made_time,	maker) " +
                                " values('" + s_org + "','" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim() + "," +
                                System.Convert.ToString(i_rec_no) + ",'000000000000000','" + ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",'" + ds_asn.Tables[0].Rows[i]["order_unit"].ToString().Trim() + "'," +
                                System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim())) + "," +
                                System.Convert.ToString(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim())) + ",'" +
                                ds_asn.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" + s_sugg_loc + "'," + ds_asn.Tables[0].Rows[i]["shelflife_day"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_cubage"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_gross"].ToString().Trim() + "," + ds_asn.Tables[0].Rows[i]["prerec_net"].ToString().Trim() + "," +
                                "'0','','','1','','0','','0','','" + ds_asn.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" +
                            ds_asn.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "','','','','','" + str_rec_no + "',0,0,'" + ds_asn.Tables[0].Rows[i]["memo"].ToString().Trim() + "','A',getdate(),'" + str_userid + "')";
                        command.CommandText = s_str;
                        SqldbCenter.ExecuteNonQuery(command);
                    }

                    if (s_pa_flag == "2") //调用上架计算存储过程
                    {
                        if (s_pallet_flag == "0") // 只有非托盘的才能调用
                        {
                            command.CommandType = CommandType.StoredProcedure;
                            command.CommandText = g_usespace + ".SP_SQL_PUTAWAY";
                            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                            command.Parameters["@sp_org"].Value = s_org;
                            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                            command.Parameters["@sp_csgor"].Value = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                            command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                            command.Parameters["@sp_asn"].Value = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                            command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                            command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                            command.Parameters.Add("@sp_recno", SqlDbType.Int);
                            command.Parameters["@sp_recno"].Value = i_rec_no;
                            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                            command.Parameters["@sp_pallet"].Value = "000000000000000";
                            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                            command.Parameters["@sp_qty"].Precision = (byte)16;      
                            command.Parameters["@sp_qty"].Scale = (byte)4;
                            command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim());
                            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                            command.Parameters["@sp_sku"].Value = ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim();
                            command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                            command.Parameters["@sp_pack"].Value = ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                            command.Parameters["@sp_user"].Value = str_userid;   
                            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                            command.Parameters["@sp_loc"].Direction = ParameterDirection.Output;
                            SqldbCenter.ExecuteNonQuery(command);
                            if (command.Parameters["@sp_loc"].Value.ToString().Trim().Substring(0, 3).ToUpper() == "ERR")
                            {
                                ls_middle = ls_middle + command.Parameters["@sp_loc"].Value.ToString().Trim();
                            }
                            command.Parameters.Clear();
                            command.CommandType = CommandType.Text;
                            if (ls_middle.Trim() != "")
                            {
                                break;
                            }
                        }
                    }

                    //修改订单明细的状态
                    s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = isnull(receive_qty_m,0) + " + ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() + "," +
                                                                       "receive_qty_s = isnull(receive_qty_s,0) + " + ds_asn.Tables[0].Rows[i]["prerec_qty_s"].ToString().Trim() + "," +
                                                                       "receive_present_qty_m = isnull(receive_present_qty_m,0) + " + ds_asn.Tables[0].Rows[i]["prerec_present_qty_m"].ToString().Trim() + "," +
                                                                       "receive_present_qty_s = isnull(receive_present_qty_s,0) + " + ds_asn.Tables[0].Rows[i]["prerec_present_qty_s"].ToString().Trim() + "," +
                                                                       "receive_day = case ltrim(rtrim(isnull(receive_day,''))) when '' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                                       "receive_status = case when isnull(receive_qty_m,0) +" + ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim() + " >= isnull(order_qty_m,0) then '2' else '1' end," +
                                                                       "main_dist = 'C',update_time = getdate(),updater='" + str_userid + "' where inv_org = '"+s_org+"' and consignor = '" + ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and " +
                                                                       "asn_no='" + ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim() + "' and asn_line_no =" + ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim();
                    command.CommandText = s_str;
                    SqldbCenter.ExecuteNonQuery(command);

                    if (s_type.Trim() == "8" || s_type.Trim() == "9" || s_type.Trim() == "4")  //说明是委外或者外协,调用存储过程
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.CommandText = g_usespace + ".SP_SQL_RECEIVE_DELEGATE";
                        command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                        command.Parameters["@sp_org"].Value = s_org;
                        command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                        command.Parameters["@sp_csgor"].Value = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                        command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                        command.Parameters["@sp_asn"].Value = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                        command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                        command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                        command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                        command.Parameters["@sp_sku"].Value = ds_asn.Tables[0].Rows[i]["sku"].ToString().Trim();
                        command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                        command.Parameters["@sp_pack"].Value = ds_asn.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                        command.Parameters.Add("@sp_qtym", SqlDbType.Decimal);
                        command.Parameters["@sp_qtym"].Precision = (byte)16;
                        command.Parameters["@sp_qtym"].Scale = (byte)4;
                        command.Parameters["@sp_qtym"].Value = System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["prerec_qty_m"].ToString().Trim());
                        command.Parameters.Add("@sp_lot6", SqlDbType.Char, 20);
                        command.Parameters["@sp_lot6"].Value = ds_asn.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim();
                        command.Parameters.Add("@sp_type", SqlDbType.Char, 1);
                        command.Parameters["@sp_type"].Value = s_type;
                        command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                        command.Parameters["@sp_user"].Value = str_userid;
                        command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                        command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                        SqldbCenter.ExecuteNonQuery(command);
                        if (command.Parameters["@sp_out"].Value.ToString().Trim() != "1")
                        {
                            ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        }
                        command.Parameters.Clear();
                        command.CommandType = CommandType.Text;
                        if (ls_middle.Trim() != "")
                        {
                            break;
                        }
                    }

                }
                //全部更新完成后修改表头的状态
                s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no ='" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "' and receive_status in ('0','1')";
                command.CommandText = s_str;
                i_rec_no = SqldbCenter.ExecuteScalar(command);
                s_str = "update "+g_usespace+".asn_order_header set arrive_day = case ltrim(rtrim(isnull(arrive_day,''))) when '' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
                if (i_rec_no > 0)//说明还没有收完
                    s_str = s_str + "arrive_status = '1',";
                else
                    s_str = s_str + "arrive_status = '2',";
                s_str = s_str + "main_dist = 'C',update_time=getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no ='" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            if (ls_middle.Trim() != "")
            {
                SqldbCenter.Rollback();
            }
            else  
            {
                SqldbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return ls_middle.Trim();
    }

    //portal收货确认,拆板,上架计算(目前只针对托盘管理的商品
    [WebMethod]
    public void Sql_confirm_protalasn(string s_org, DataSet ds_asn, string str_userid, string str_day)
    {
        string s_str, str_precon, str_con, str_asn, str_preasn;
        int i_line, i_pre_line, i_max_recno;
        decimal d_1, d_2;
        decimal d_ls;
        str_precon = "";
        str_preasn = "";
        i_pre_line = 0;
        d_1 = 0;
        d_2 = 0;
        i_max_recno = 0;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //循环插入收货确认的数据
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                if (i == 0)
                {
                    str_precon = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    str_preasn = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    i_pre_line = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    d_1 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()), 4);
                    d_2 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                    //得到最大行号
                    s_str = "select isnull(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' " +
                            "and asn_no ='" + str_preasn + "' and asn_line_no =" + System.Convert.ToInt32(i_pre_line);
                    command.CommandText = s_str;
                    i_max_recno = SqldbCenter.ExecuteScalar(command);
                    i_max_recno = i_max_recno + 1;
                }
                str_con = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_asn = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                i_line = System.Convert.ToInt32(ds_asn.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                if (str_con != str_precon || str_asn != str_preasn || i_line != i_pre_line) //说明换了收货明细,修改相应的数据
                {
                    //插入前一条收货明细 
                    d_ls = d_1 + d_2;
                    s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                                    "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                                    "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                    "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                    "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                            " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",sku,		pack_code,	order_price,	order_unit," +
                            "Round(" + System.Convert.ToString(d_ls) + " * isnull(cubage,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * isnull(gross_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4)," +
                            "Round(" + System.Convert.ToString(d_ls) + " * isnull(net_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),shelflife_day," + System.Convert.ToString(d_1) + ",Round(" + System.Convert.ToString(d_1) + " * isnull(convert_modulus,1),4)," +
                            System.Convert.ToString(d_2) + ",Round(" + System.Convert.ToString(d_2) + " * isnull(convert_modulus,1),4),main_sub_flag,	convert_modulus,convert(char(10),getdate(),102),'1','" + str_day + "',convert(char(10),getdate(),102),'','','','','','','',''," +
                            "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',getdate(),'" + str_userid + "'" +
                            " from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and asn_no = '" + str_preasn + "' and asn_line_no = " + System.Convert.ToString(i_pre_line);
                    command.CommandText = s_str;
                    SqldbCenter.ExecuteNonQuery(command);
                    //更新前一条收货数据
                    //修改订单明细的状态
                    s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = isnull(receive_qty_m,0) + " + System.Convert.ToString(d_1) + "," +
                                                                       "receive_qty_s = isnull(receive_qty_s,0) + Round(" + System.Convert.ToString(d_1) + " * isnull(convert_modulus,1),4)," +
                                                                       "receive_present_qty_m = isnull(receive_present_qty_m,0) + " + System.Convert.ToString(d_2) + "," +
                                                                       "receive_present_qty_s = isnull(receive_present_qty_s,0) + Round(" + System.Convert.ToString(d_2) + " * isnull(convert_modulus,1),4)," +
                                                                       "receive_day = case ltrim(rtrim(isnull(receive_day,'tmp'))) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                                       "receive_status = case when isnull(receive_qty_m,0) +" + System.Convert.ToString(d_1) + " >= isnull(order_qty_m,0) then '2' else '1' end," +
                                                                       "main_dist = 'C',update_time = getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and " +
                                                                       "asn_no='" + str_preasn + "' and asn_line_no =" + System.Convert.ToString(i_pre_line);
                    command.CommandText = s_str;
                    SqldbCenter.ExecuteNonQuery(command);
                    //得到新的收货信息
                    d_1 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()), 4);
                    d_2 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                    //得到最大行号
                    s_str = "select isnull(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + str_con + "' " +
                            "and asn_no ='" + str_asn + "' and asn_line_no =" + System.Convert.ToInt32(i_line);
                    command.CommandText = s_str;
                    i_max_recno = SqldbCenter.ExecuteScalar(command);
                    i_max_recno = i_max_recno + 1;
                    str_precon = str_con;
                    str_preasn = str_asn;
                    i_pre_line = i_line;
                }
                else
                {
                    if (i != 0)  //说明不是第一条要累加
                    {
                        d_1 = d_1 + Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()), 4);
                        d_2 = d_2 + Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                    }
                }
                //插入拆板的数据
                d_ls = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["quantity"].ToString().Trim()) + System.Convert.ToDecimal(ds_asn.Tables[0].Rows[i]["present_quantity"].ToString().Trim()), 4);
                s_str = "insert into " + g_usespace + ".asn_pallet_split(inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,	pallet_no,	sku,		pack_code,	order_price,order_unit," +
                                                                "pallet_qty_m,	pallet_qty_s,	main_sub_flag,	convert_modulus,	shelflife_day, cubage,		gross_weight," +
                                                                "net_weight,	spliter,	split_status,	split_date,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                                "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                                "lot_attribute13,	lot_attribute14,	lot_attribute15,	standby_1,	standby_2,	standby_3,	standby_4,	standby_5," +
                                                                "standby_6,	standby_7,	memo,		main_dist,	made_time,	maker)" +
                        " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",'" + ds_asn.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "',sku,pack_code,order_price,order_unit," +
                        System.Convert.ToString(d_ls) + ",Round(" + System.Convert.ToString(d_ls) + " * isnull(convert_modulus,1),4),main_sub_flag,	convert_modulus,shelflife_day," +
                        "Round(" + System.Convert.ToString(d_ls) + " * isnull(cubage,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * isnull(gross_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4)," +
                        "Round(" + System.Convert.ToString(d_ls) + " * isnull(net_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),'" + str_userid + "','0',convert(char(10),getdate(),102),'" + str_day + "',convert(char(10),getdate(),102),'','','','','','','',''," +
                        "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',getdate(),'" + str_userid + "'" +
                        " from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line);
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            //出来之后,插入收货明细和更新收货明细
            //插入前一条收货明细 
            d_ls = d_1 + d_2;
            s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                            "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                            "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                            "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                            "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                    " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",sku,		pack_code,	order_price,	order_unit," +
                    "Round(" + System.Convert.ToString(d_ls) + " * isnull(cubage,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * isnull(gross_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4)," +
                    "Round(" + System.Convert.ToString(d_ls) + " * isnull(net_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),shelflife_day," + System.Convert.ToString(d_1) + ",Round(" + System.Convert.ToString(d_1) + " * isnull(convert_modulus,1),4)," +
                    System.Convert.ToString(d_2) + ",Round(" + System.Convert.ToString(d_2) + " * isnull(convert_modulus,1),4),main_sub_flag,	convert_modulus,convert(char(10),getdate(),102),'1','" + str_day + "',convert(char(10),getdate(),102),'','','','','','','',''," +
                    "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',getdate(),'" + str_userid + "'" +
                    " from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and asn_no = '" + str_preasn + "' and asn_line_no = " + System.Convert.ToString(i_pre_line);
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //更新前一条收货数据
            //修改订单明细的状态
            s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = isnull(receive_qty_m,0) + " + System.Convert.ToString(d_1) + "," +
                                                               "receive_qty_s = isnull(receive_qty_s,0) + Round(" + System.Convert.ToString(d_1) + " * isnull(convert_modulus,1),4)," +
                                                               "receive_present_qty_m = isnull(receive_present_qty_m,0) + " + System.Convert.ToString(d_2) + "," +
                                                               "receive_present_qty_s = isnull(receive_present_qty_s,0) + Round(" + System.Convert.ToString(d_2) + " * isnull(convert_modulus,1),4)," +
                                                               "receive_day = case ltrim(rtrim(isnull(receive_day,'tmp'))) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                               "receive_status = case when isnull(receive_qty_m,0) +" + System.Convert.ToString(d_1) + " >= isnull(order_qty_m,0) then '2' else '1' end," +
                                                               "main_dist = 'C',update_time = getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and " +
                                                               "asn_no='" + str_preasn + "' and asn_line_no =" + System.Convert.ToString(i_pre_line);
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //出来之后修改整个订单的状态,并且进行相应的上架计算
            int i_rec_no;
            str_precon = ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim();
            str_preasn = ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim();
            for (int i = 0; i < ds_asn.Tables[0].Rows.Count; i++)
            {
                str_con = ds_asn.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_asn = ds_asn.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                if (str_con != str_precon || str_asn != str_preasn)  //说明变化了,更新前一个
                {
                    //全部更新完成后修改表头的状态
                    s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "' and receive_status in ('0','1')";
                    command.CommandText = s_str;
                    i_rec_no = SqldbCenter.ExecuteScalar(command);
                    s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case ltrim(rtrim(isnull(arrive_day,'tmp'))) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
                    if (i_rec_no > 0)//说明还没有收完
                        s_str = s_str + "arrive_status = '1',";
                    else
                        s_str = s_str + "arrive_status = '2',";
                    s_str = s_str + "main_dist = 'C',update_time=getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "'";
                    command.CommandText = s_str;
                    SqldbCenter.ExecuteNonQuery(command);
                    //按订单调用上架计算的存储过程
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_PUTAWAY_LIST";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = s_org;
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = str_precon;
                    command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
                    command.Parameters["@sp_asnno"].Value = str_preasn;
                    command.Parameters.Add("@sp_asnline", SqlDbType.Int);
                    command.Parameters["@sp_asnline"].Value = 0;
                    command.Parameters.Add("@sp_recline", SqlDbType.Int);
                    command.Parameters["@sp_recline"].Value = 0;
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = "";
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = str_userid;
                    SqldbCenter.ExecuteNonQuery(command);
                    command.Parameters.Clear();
                    command.CommandType = CommandType.Text;
                    str_precon = str_con;
                    str_preasn = str_asn;
                }
            }
            //出来在更新一次
            //全部更新完成后修改表头的状态
            s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "' and receive_status in ('0','1')";
            command.CommandText = s_str;
            i_rec_no = SqldbCenter.ExecuteScalar(command);
            s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case ltrim(rtrim(isnull(arrive_day,'tmp'))) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
            if (i_rec_no > 0)//说明还没有收完
                s_str = s_str + "arrive_status = '1',";
            else
                s_str = s_str + "arrive_status = '2',";
            s_str = s_str + "main_dist = 'C',update_time=getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_precon + "' and asn_no ='" + str_preasn + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //按订单调用上架计算的存储过程
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_SQL_PUTAWAY_LIST";
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = str_precon;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = str_preasn;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = 0;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = 0;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = "";
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10); 
            command.Parameters["@sp_user"].Value = str_userid;
            SqldbCenter.ExecuteNonQuery(command);
            command.Parameters.Clear();
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw; 
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //portal收货确认,拆板,上架计算(箱级管理)
    //ds_asn 一拖盘的收货  ,ds_box箱标
    [WebMethod]
    public void Sql_confirm_protalasnbox(string s_org, DataSet ds_asn, DataSet ds_box, string str_userid, string str_day)
    {
        string s_str, str_con, str_asn, str_select;
        int i_line, i_max_recno, i_rec_no;
        decimal d_1, d_2;
        decimal d_ls;
        d_1 = 0;
        d_2 = 0;
        i_max_recno = 0;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //插入收货确认的数据
            str_con = ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim();
            str_asn = ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim();
            i_line = System.Convert.ToInt32(ds_asn.Tables[0].Rows[0]["asn_line_no"].ToString().Trim());
            d_1 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[0]["quantity"].ToString().Trim()), 4);
            d_2 = Math.Round(System.Convert.ToDecimal(ds_asn.Tables[0].Rows[0]["present_quantity"].ToString().Trim()), 4);
            //得到最大行号
            s_str = "select isnull(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '"+s_org+"' and consignor = '" + str_con + "' " +
                    "and asn_no ='" + str_asn + "' and asn_line_no =" + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            i_max_recno = SqldbCenter.ExecuteScalar(command);
            i_max_recno = i_max_recno + 1;
            //插入前一条收货明细 
            d_ls = d_1 + d_2;
            s_str = "insert into " + g_usespace + ".asn_receive_detail(	inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,       sku,		pack_code,	order_price,	order_unit," +
                                            "cubage,		gross_weight,	net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m,	receive_present_qty_s," +
                                            "main_sub_flag,	convert_modulus,	receive_day,	fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                            "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                            "lot_attribute13,	lot_attribute14,	lot_attribute15,standby_1,standby_2,standby_3,standby_4,standby_5,standby_6,standby_7,memo,main_dist,made_time,maker)" +
                    " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",sku,		pack_code,	order_price,	order_unit," +
                    "Round(" + System.Convert.ToString(d_ls) + " * isnull(cubage,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * isnull(gross_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4)," +
                    "Round(" + System.Convert.ToString(d_ls) + " * isnull(net_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),shelflife_day," + System.Convert.ToString(d_1) + ",Round(" + System.Convert.ToString(d_1) + " * isnull(convert_modulus,1),4)," +
                    System.Convert.ToString(d_2) + ",Round(" + System.Convert.ToString(d_2) + " * isnull(convert_modulus,1),4),main_sub_flag,	convert_modulus,convert(char(10),getdate(),102),'1','" + str_day + "',convert(char(10),getdate(),102),'','','','','','','',''," +
                    "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',getdate(),'" + str_userid + "'" +
                    " from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //修改订单明细的状态
            s_str = "update " + g_usespace + ".asn_order_detail set receive_qty_m = isnull(receive_qty_m,0) + " + System.Convert.ToString(d_1) + "," +
                                                               "receive_qty_s = isnull(receive_qty_s,0) + Round(" + System.Convert.ToString(d_1) + " * isnull(convert_modulus,1),4)," +
                                                               "receive_present_qty_m = isnull(receive_present_qty_m,0) + " + System.Convert.ToString(d_2) + "," +
                                                               "receive_present_qty_s = isnull(receive_present_qty_s,0) + Round(" + System.Convert.ToString(d_2) + " * isnull(convert_modulus,1),4)," +
                                                               "receive_day = case trim(isnull(receive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else receive_day end," +
                                                               "receive_status = case when isnull(receive_qty_m,0) +" + System.Convert.ToString(d_1) + " >= isnull(order_qty_m,0) then '2' else '1' end," +
                                                               "main_dist = 'C',update_time = getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and " +
                                                               "asn_no='" + str_asn + "' and asn_line_no =" + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //插入拆板的数据
            s_str = "insert into " + g_usespace + ".asn_pallet_split(inv_org,consignor,	asn_no,		asn_line_no,	receive_line_no,	pallet_no,	sku,		pack_code,	order_price,order_unit," +
                                                            "pallet_qty_m,	pallet_qty_s,	main_sub_flag,	convert_modulus,	shelflife_day, cubage,		gross_weight," +
                                                            "net_weight,	spliter,	split_status,	split_date,	lot_attribute1,	lot_attribute2,	lot_attribute3,	lot_attribute4," +
                                                            "lot_attribute5,	lot_attribute6,	lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11,	lot_attribute12," +
                                                            "lot_attribute13,	lot_attribute14,	lot_attribute15,	standby_1,	standby_2,	standby_3,	standby_4,	standby_5," +
                                                            "standby_6,	standby_7,	memo,		main_dist,	made_time,	maker)" +
                    " select inv_org,consignor,	asn_no,		asn_line_no," + System.Convert.ToString(i_max_recno) + ",'" + ds_asn.Tables[0].Rows[0]["pallet_no"].ToString().Trim() + "',sku,pack_code,order_price,order_unit," +
                    System.Convert.ToString(d_ls) + ",Round(" + System.Convert.ToString(d_ls) + " * isnull(convert_modulus,1),4),main_sub_flag,	convert_modulus,shelflife_day," +
                    "Round(" + System.Convert.ToString(d_ls) + " * isnull(cubage,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),Round(" + System.Convert.ToString(d_ls) + " * isnull(gross_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4)," +
                    "Round(" + System.Convert.ToString(d_ls) + " * isnull(net_weight,0) / (isnull(order_qty_m,0) + isnull(present_qty_m,0)),4),'" + str_userid + "','0',convert(char(10),getdate(),102),'" + str_day + "',convert(char(10),getdate(),102),'','','','','','','',''," +
                    "'','','','','',standby_1,	standby_2,	standby_3,	standby_4,	standby_5,standby_6,standby_7,memo,'A',getdate(),'" + str_userid + "'" +
                    " from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line);
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //更细托盘号到箱级标签
            str_select = "";
            for (int i = 0; i < ds_box.Tables[0].Rows.Count; i++)
            {
                str_select = str_select + "'" + ds_box.Tables[0].Rows[i]["box_rfid"].ToString().Trim() + "',";
            }
            str_select = str_select.Substring(0, str_select.Length - 1);
            s_str = "update " + g_usespace + ".asn_order_rfid set pallet_no = '" + ds_asn.Tables[0].Rows[0]["pallet_no"].ToString().Trim() + "',status = '1' where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no = '" + str_asn + "' and asn_line_no = " + System.Convert.ToString(i_line) +
                    " and box_rfid in (" + str_select + ") and status = '0'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //全部更新完成后修改表头的状态
            s_str = "select count(*) from " + g_usespace + ".asn_order_detail where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no ='" + str_asn + "' and receive_status in ('0','1')";
            command.CommandText = s_str;
            i_rec_no = SqldbCenter.ExecuteScalar(command);
            s_str = "update " + g_usespace + ".asn_order_header set arrive_day = case trim(isnull(arrive_day,'tmp')) when 'tmp' then '" + DateTime.Now.ToString("yyyy.MM.dd") + "' else arrive_day end,";
            if (i_rec_no > 0)//说明还没有收完
                s_str = s_str + "arrive_status = '1',";
            else
                s_str = s_str + "arrive_status = '2',";
            s_str = s_str + "main_dist = 'C',update_time=getdate(),updater='" + str_userid + "' where inv_org = '" + s_org + "' and consignor = '" + str_con + "' and asn_no ='" + str_asn + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //按订单调用上架计算的存储过程
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_SQL_PUTAWAY_LIST";
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = str_con;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = str_asn;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = 0;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = 0;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = "";
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = str_userid;
            SqldbCenter.ExecuteNonQuery(command);
            command.Parameters.Clear();
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //正大富通版修改托盘号和数量
    [WebMethod]
    public void Sql_modify_pallet_new(string s_org, DataSet dtst, string strsql, string s_user)
    {
        string str_update_sql;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            //然后循环修改inv_sku_pallet里面的数据
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    str_update_sql = "update " + g_usespace + ".inv_sku_pallet set pallet_no = '" + dtst.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "',stock_qty_m = isnull(stock_qty_m,0) - " + dtst.Tables[0].Rows[i]["old_pallet_m"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["pallet_qty_m"].ToString().Trim() +
                        ",stock_qty_s = isnull(stock_qty_s,0) - " + dtst.Tables[0].Rows[i]["old_pallet_s"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["pallet_qty_s"].ToString().Trim() + ",cubage = isnull(cubage,0) - " + dtst.Tables[0].Rows[i]["old_cubage"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["cubage"].ToString().Trim() +
                        ",gross_weight = isnull(gross_weight,0) - " + dtst.Tables[0].Rows[i]["old_gross_weight"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["gross_weight"].ToString().Trim() + ",net_weight = isnull(net_weight,0) - " + dtst.Tables[0].Rows[i]["old_net_weight"].ToString().Trim() + " + " + dtst.Tables[0].Rows[i]["net_weight"].ToString().Trim() +
                        ",update_time = getdate(),updater = '" + s_user.Trim() + "' where inv_org = '" + s_org.Trim() + "' and batchno = '" + dtst.Tables[0].Rows[i]["batchno"].ToString().Trim() + "' and location_code = 'STAGE' and pallet_no = '" + dtst.Tables[0].Rows[i]["old_pallet"].ToString().Trim() + "'";
                    command.CommandType = CommandType.Text;
                    command.CommandText = str_update_sql;
                    SqldbCenter.ExecuteNonQuery(command);
                }
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //上架计算存储过程
    [WebMethod]
    public void Sql_exec_proc_putaway(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PUTAWAY_LIST");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //新上架计算存储过程
    [WebMethod]
    public string Sql_exec_proc_putaway_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PUTAWAY_LIST_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //判断输入的上架库位是否有效 
    [WebMethod]
    public string Sql_exec_proc_judgeloc(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_loc)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_JUDGE_LOC");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
            command.Parameters["@sp_asn"].Value = s_asn_no;
            command.Parameters.Add("@sp_lineno", SqlDbType.Int);
            command.Parameters["@sp_lineno"].Value = i_asnno;
            command.Parameters.Add("@sp_recno", SqlDbType.Int);
            command.Parameters["@sp_recno"].Value = i_recno;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }


    //正大富通版判断输入的上架库位是否有效 
    [WebMethod]
    public string Sql_exec_proc_judgeloc_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, int i_putaway, string s_pallet, string s_loc)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_JUDGE_LOC_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
            command.Parameters["@sp_asn"].Value = s_asn_no;
            command.Parameters.Add("@sp_lineno", SqlDbType.Int);
            command.Parameters["@sp_lineno"].Value = i_asnno;
            command.Parameters.Add("@sp_recno", SqlDbType.Int);
            command.Parameters["@sp_recno"].Value = i_recno;
            command.Parameters.Add("@sp_putawayno", SqlDbType.Int);
            command.Parameters["@sp_putawayno"].Value = i_putaway;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }


    //修改实际上架库位，并且直接上架确认
    [WebMethod]
    public string Sql_exec_proc_pasaveandcon(string s_org, DataSet ds_save,string s_sql,string s_method, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();  
            SqldbCenter.BeginTransaction();
            command.CommandText = s_sql;
            SqldbCenter.updatedatabaser(command, ds_save);
            for (int i = 0; i < ds_save.Tables[0].Rows.Count; i++) //有实际库位并且没有确认的进行确认
            {
                if (ds_save.Tables[0].Rows[i]["putaway_status"].ToString().Trim() == "0" && ds_save.Tables[0].Rows[i]["fact_location"].ToString().Trim() != "") //说明需要确认
                {
                    command.CommandText = g_usespace + ".SP_SQL_PA_CONFIRM";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = s_org;
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_save.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_save.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_recno", SqlDbType.Int);
                    command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_save.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
                    command.Parameters["@sp_method"].Value = s_method;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //新修改实际上架库位，并且直接上架确认
    [WebMethod]
    public string Sql_exec_proc_pasaveandcon_new(string s_org, DataSet ds_save, string s_sql, string s_method, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = s_sql;
            SqldbCenter.updatedatabaser(command, ds_save);
            for (int i = 0; i < ds_save.Tables[0].Rows.Count; i++) //有实际库位并且没有确认的进行确认
            {
                if (ds_save.Tables[0].Rows[i]["putaway_status"].ToString().Trim() == "0" && ds_save.Tables[0].Rows[i]["fact_location"].ToString().Trim() != "") //说明需要确认
                {
                    command.CommandText = g_usespace + ".SP_SQL_PA_CONFIRM_NEW";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = s_org;
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_save.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_save.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_recno", SqlDbType.Int);
                    command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_save.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_putawayno", SqlDbType.Int);
                    command.Parameters["@sp_putawayno"].Value = System.Convert.ToInt32(ds_save.Tables[0].Rows[i]["putaway_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_pa_qtym", SqlDbType.Decimal);
                    command.Parameters["@sp_pa_qtym"].Precision = (byte)16;
                    command.Parameters["@sp_pa_qtym"].Scale = (byte)4;
                    command.Parameters["@sp_pa_qtym"].Value = System.Convert.ToDecimal(ds_save.Tables[0].Rows[i]["pa_qty_m"].ToString().Trim());
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
                    command.Parameters["@sp_method"].Value = s_method;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //上架确认存储过程
    [WebMethod]
    public string Sql_exec_proc_pacon(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_method, string s_user, string str_fact_loc)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PA_CON_LIST");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
            command.Parameters["@sp_method"].Value = s_method;
            command.Parameters.Add("@sp_fact_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_fact_loc"].Value = str_fact_loc;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_output", SqlDbType.VarChar, 50);
            command.Parameters["@sp_output"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_output"].Value.ToString().Trim();
    }

    //新上架确认存储过程
    [WebMethod]
    public string Sql_exec_proc_pacon_new(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_method, string s_user, string str_fact_loc)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PA_CON_LIST_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
            command.Parameters["@sp_method"].Value = s_method;
            command.Parameters.Add("@sp_fact_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_fact_loc"].Value = str_fact_loc;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_output", SqlDbType.VarChar, 255);
            command.Parameters["@sp_output"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_output"].Value.ToString().Trim();
    }

    //上架取消 
    [WebMethod]
    public string Sql_exec_proc_pacancel(DataSet ds_pacancel, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_pacancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_pacancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_PA_CANCEL";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_pacancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_pacancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_pacancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_recno", SqlDbType.Int);
                    command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_pacancel.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_memo"].Value = ds_pacancel.Tables[0].Rows[i]["reason"].ToString().Trim();
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear(); 
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //新上架取消 
    [WebMethod]
    public string Sql_exec_proc_pacancel_new(DataSet ds_pacancel, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_pacancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_pacancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_PA_CANCEL_NEW";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_pacancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_pacancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_pacancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_recno", SqlDbType.Int);
                    command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_pacancel.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_putawayno", SqlDbType.Int);
                    command.Parameters["@sp_putawayno"].Value = System.Convert.ToInt32(ds_pacancel.Tables[0].Rows[i]["putaway_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_memo"].Value = ds_pacancel.Tables[0].Rows[i]["reason"].ToString().Trim();
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //收货取消ds_receive_cancel
    [WebMethod]
    public string Sql_exec_proc_receive_cancel(DataSet ds_receive_cancel, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_receive_cancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_receive_cancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_RECEIVE_CANCEL";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_receive_cancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_receive_cancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_receive_cancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_recno", SqlDbType.Int);
                    command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //新收货取消ds_receive_cancel
    [WebMethod]
    public string Sql_exec_proc_receive_cancel_new(DataSet ds_receive_cancel, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_receive_cancel.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_receive_cancel.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_RECEIVE_CANCEL_NEW";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_receive_cancel.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_receive_cancel.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                    command.Parameters["@sp_asn"].Value = ds_receive_cancel.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                    command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                    command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_recno", SqlDbType.Int);
                    command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_receive_cancel.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    #endregion
    #region 出库单管理的函数

    //拣货数量批量新增
    [WebMethod]
    public string Sql_exec_proc_pickbatch_rf(DataSet ds_batch_pick, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;  
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try    
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //调用车载拣货确认的存储过程
            if (ds_batch_pick.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_batch_pick.Tables[0].Rows.Count; i++)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_PICK_RF";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_batch_pick.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_batch_pick.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                    command.Parameters["@sp_so"].Value = ds_batch_pick.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                    command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_batch_pick.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                    command.Parameters["@sp_sku"].Value = ds_batch_pick.Tables[0].Rows[i]["sku"].ToString().Trim();
                    command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                    command.Parameters["@sp_loc"].Value = ds_batch_pick.Tables[0].Rows[i]["location_code"].ToString().Trim();
                    command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                    command.Parameters["@sp_bat"].Value = ds_batch_pick.Tables[0].Rows[i]["batchno"].ToString().Trim();
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_batch_pick.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                    command.Parameters["@sp_qty"].Precision = (byte)16;
                    command.Parameters["@sp_qty"].Scale = (byte)4;
                    command.Parameters["@sp_qty"].Value = Math.Round(System.Convert.ToDecimal(ds_batch_pick.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim()), 4);
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_lot06", SqlDbType.Char, 20);
                    command.Parameters["@sp_lot06"].Value = ds_batch_pick.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim();
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 256);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "1")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //删除整张出库单信息，存在表头和明细，所以要在一个事物里面删除
    [WebMethod]
    public void Sql_del_sono(string s_org, string str_sto, string str_soh)
    {
        string s_str;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //判断是否存在波次中
            s_str = "select wave_flag from " + g_usespace + ".so_ship_header where inv_org = '"+s_org+"' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
            s_str = Sql_exec_selectstring(s_str);
            if (s_str == "1") //说明存在波次中，需要删除
            {
                s_str = "delete " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            //删除明细
            s_str = "delete " + g_usespace + ".so_ship_detail where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            //在删除表头
            s_str = "delete " + g_usespace + ".so_ship_header where inv_org = '" + s_org + "' and consignor ='" + str_sto + "' and so_no ='" + str_soh + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //拆分出库单
    [WebMethod]
    public void Sql_exec_proc_shipbom(string s_org, string s_consignor, string s_so_no, string s_sku, decimal d_shipm, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_SPLIT_SHIP");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_so_no", SqlDbType.Char, 20);
            command.Parameters["@sp_so_no"].Value = s_so_no;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_shipm", SqlDbType.Decimal);
            command.Parameters["@sp_shipm"].Precision = (byte)16;
            command.Parameters["@sp_shipm"].Scale = (byte)4;
            command.Parameters["@sp_shipm"].Value = d_shipm;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //波次做成
    [WebMethod]
    public void Sql_exec_makewave(string s_org, DataSet ds_tmp, string s_user,string str_flag)
    {
        //str_flag  0则是新添加的  1则是追加的不需要表头
        string s_str;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (str_flag == "0")
            {
                //首先插入波次号
                s_str = "insert into " + g_usespace + ".so_ship_wave (inv_org,consignor,	wave_no,	wave_description,	wave_day," +
                                                                   "confirm_day,	confirmer,	wave_status,	standby_1," +
                                                                   "standby_2,	standby_3,	standby_4,	standby_5," +
                                                                   "memo,		main_dist,	made_time,	maker)" +
                                                   " values ('"+s_org+"','" + ds_tmp.Tables[0].Rows[0]["consignor"].ToString().Trim() + "','" + ds_tmp.Tables[0].Rows[0]["wave_no"].ToString().Trim() + "','',convert(char(10),getdate(),102)," +
                                                   "'','','0','','','',0," + ds_tmp.Tables[0].Rows[0]["attribute"].ToString().Trim() + ",'','A',getdate(),'" + s_user + "')";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            //循环插入明细
            for (int i = 0; i < ds_tmp.Tables[0].Rows.Count; i++)
            {
                s_str = "insert into " + g_usespace + ".so_ship_wavedetail (inv_org,consignor,	wave_no,	so_no,		standby_1,"+
	                                                                        "standby_2,	standby_3,	memo,		main_dist,"+
	                                                                        "made_time,	maker)" +
                                               " values ('"+s_org+"','" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_tmp.Tables[0].Rows[i]["wave_no"].ToString().Trim() + "','" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'," +
                                               "'','',0,'','A',getdate(),'" + s_user + "')";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
                //更改出库单为波次做成
                s_str = "update " + g_usespace + ".so_ship_header set wave_flag = '1',main_dist='C',update_time=getdate(),updater='" + s_user + "' where inv_org = '"+s_org+"' and consignor='" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and so_no ='" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //波次删除
    [WebMethod]
    public void Sql_exec_delwave(string s_org, DataSet ds_tmp,string s_user)
    {
        int i_count;
        string s_str;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //循环删除明细
            for (int i = 0; i < ds_tmp.Tables[0].Rows.Count; i++)
            {
                s_str = "delete from " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and consignor = '" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and wave_no='" + ds_tmp.Tables[0].Rows[i]["wave_no"].ToString().Trim() + "' and so_no='" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
                //更改出库单为波次未做成
                s_str = "update " + g_usespace + ".so_ship_header set wave_flag = '0',main_dist='C',update_time=getdate(),updater='" + s_user + "' where inv_org = '" + s_org + "' and consignor='" + ds_tmp.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and so_no ='" + ds_tmp.Tables[0].Rows[i]["so_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            //出来判断该波次是否还有相应的数据，如果没有则删除相应的波次好
            s_str = "select count(*) from " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and wave_no ='" + ds_tmp.Tables[0].Rows[0]["wave_no"].ToString().Trim() + "'";
            command.CommandText = s_str;
            i_count = SqldbCenter.ExecuteScalar(command);
            if (i_count <= 0) //说明没有数据了删除表头
            {
                s_str = "delete from " + g_usespace + ".so_ship_wave where inv_org = '" + s_org + "' and wave_no='" + ds_tmp.Tables[0].Rows[0]["wave_no"].ToString().Trim() + "'";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //一单拣货
    [WebMethod]
    public void Sql_exec_proc_billpick(string s_org, string s_consignor, string s_so_no, string s_wave, string s_preparer, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_BILL_PICK");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_wave", SqlDbType.Char, 20);
            command.Parameters["@sp_wave"].Value = s_wave;
            command.Parameters.Add("@sp_preparer", SqlDbType.Char, 20);
            command.Parameters["@sp_preparer"].Value = s_preparer;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //一团火 一单拣货
    [WebMethod]
    public void Sql_exec_proc_billpick_yth(string s_org, string s_consignor, string s_so_no, string s_wave, string s_preparer, string s_user, string s_shopcode, string s_linecode)
    {
        string s_str;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();

            s_str = "delete " + g_usespace + ".so_push  where inv_org = '" + s_org + "' and consignor='" + s_consignor + "' and  so_no='" + s_so_no + "' ";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);

            // 插入so_push 表
            s_str = "insert into " + g_usespace + ".so_push (inv_org,consignor,so_no,customer_code,cstandby_1,push_flag,maker,made_time) values ('" + s_org + "','" + s_consignor + "','" + s_so_no + "','" + s_shopcode + "','" + s_linecode + "','0','" + s_user + "',getdate() ) ";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);

            // 一单拣货
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_SQL_BILL_PICK";
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_wave", SqlDbType.Char, 20);
            command.Parameters["@sp_wave"].Value = s_wave;
            command.Parameters.Add("@sp_preparer", SqlDbType.Char, 20);
            command.Parameters["@sp_preparer"].Value = s_preparer;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //正大富通一单拣货
    [WebMethod]
    public string Sql_exec_proc_billpick_new(string s_org, string s_consignor, string s_so_no, string s_wave, string s_preparer, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_BILL_PICK_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_wave", SqlDbType.Char, 20);
            command.Parameters["@sp_wave"].Value = s_wave;
            command.Parameters.Add("@sp_preparer", SqlDbType.Char, 20);
            command.Parameters["@sp_preparer"].Value = s_preparer;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //二次备料拣货
    [WebMethod]
    public string Sql_exec_proc_BillRePick(DataSet ds_repick, string s_preparer, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_repick.Tables[0].Rows.Count; i++)
            {
                command.CommandText = g_usespace + ".SP_SQL_BILL_REPICK"; 
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_repick.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_repick.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                command.Parameters["@sp_so"].Value = ds_repick.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("@sp_wave", SqlDbType.Char, 20);
                command.Parameters["@sp_wave"].Value = ds_repick.Tables[0].Rows[i]["wave_no"].ToString().Trim();
                command.Parameters.Add("@sp_preparer", SqlDbType.Char, 20);
                command.Parameters["@sp_preparer"].Value = s_preparer;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.Char, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //波次拣货
    [WebMethod]
    public void Sql_exec_proc_wavepick(string s_org, string s_consignor, string s_wave, string s_preparer, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_WAVE_PICK");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_waveno", SqlDbType.Char, 20);
            command.Parameters["@sp_waveno"].Value = s_wave;
            command.Parameters.Add("@sp_preparer", SqlDbType.Char, 20);
            command.Parameters["@sp_preparer"].Value = s_preparer;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception) 
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //正大富通波次拣货
    [WebMethod]
    public string Sql_exec_proc_wavepick_new(string s_org, string s_consignor, string s_wave, string s_preparer, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_WAVE_PICK_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_waveno", SqlDbType.Char, 20);
            command.Parameters["@sp_waveno"].Value = s_wave;
            command.Parameters.Add("@sp_preparer", SqlDbType.Char, 20);
            command.Parameters["@sp_preparer"].Value = s_preparer;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //调用存储过程
    //分配数量新增
    [WebMethod]
    public string Sql_exec_proc_allocadd(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, decimal d_qty, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ALLOC_ADD");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //分配数量修改
    [WebMethod]
    public string Sql_exec_proc_allocmodify(string s_org, DataSet ds_modify, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            decimal d_qty;
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_SQL_ALLOC_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                command.Parameters["@sp_so"].Value = ds_modify.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                command.Parameters["@sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = d_qty;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.Char, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //分配数量删除
    [WebMethod]
    public string Sql_exec_proc_allocdel(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, decimal d_qty, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ALLOC_DEL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku; 
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.Char, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //出库单分配取消
    [WebMethod]
    public string Sql_exec_proc_alloccancel(string s_org, DataSet ds_alloc, string s_user)
    {
        string str_consignor, str_sono;
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_alloc.Tables[0].Rows.Count; i++)
            {
                str_consignor = ds_alloc.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_sono = ds_alloc.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_SQL_ALLOC_CANCEL";
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = str_consignor;
                command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                command.Parameters["@sp_so"].Value = str_sono;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.Char, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //拣货确认
    [WebMethod]
    public string Sql_pick_confirm(string s_org, DataSet dtst, string strsql, string s_consignor, string s_so_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_SQL_PICK_LIST";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;  
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;  
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                SqldbCenter.Rollback();
            }
            else
            {
                SqldbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //波次拣货确认
    [WebMethod]
    public string Sql_wave_confirm(string s_org, string s_consignor, string s_wave_no, string s_user, string s_flag)
    {
        ////s_flag  0说明是分配到库位, 1 说明是分配到托盘批次
        string str_ls_middle;
        string str_sql;
        DataSet ds_so;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            str_sql = "select so_no from " + g_usespace + ".so_ship_wavedetail where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and wave_no = '" + s_wave_no + "' order by so_no";
            command.CommandType = CommandType.Text;
            command.CommandText = str_sql;
            ds_so = SqldbCenter.ExecuteQuery(command);
            SqldbCenter.BeginTransaction();
            if (ds_so.Tables[0].Rows.Count > 0) //说明有出库单要确认
            {
                for (int i = 0; i < ds_so.Tables[0].Rows.Count; i++)
                {
                    //首先更新状态是0的拣货信息到tmp_pick_qty_m
                    if (s_flag.Trim() == "0")
                    {
                        str_sql = "update " + g_usespace + ".so_pick_detail set tmp_pick_qty_m = isnull(plan_pick_qty_m,0) - isnull(pick_qty_m,0),tmp_pick_qty_s = isnull(plan_pick_qty_s,0) - isnull(pick_qty_s,0) where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and so_no = '" +
                                  ds_so.Tables[0].Rows[i]["so_no"].ToString().Trim() + "' and batchno = '0' and pallet_no = '0' and pcik_status in ('0','3')";
                    }
                    else
                    {
                        str_sql = "update " + g_usespace + ".so_pick_detail set tmp_pick_qty_m = isnull(plan_pick_qty_m,0) - isnull(pick_qty_m,0),tmp_pick_qty_s = isnull(plan_pick_qty_s,0) - isnull(pick_qty_s,0) where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and so_no = '" +
                                  ds_so.Tables[0].Rows[i]["so_no"].ToString().Trim() + "' and pcik_status in ('0','3')";
                    }
                    command.CommandType = CommandType.Text;
                    command.CommandText = str_sql;
                    SqldbCenter.ExecuteNonQuery(command);
                    //然后调用存储过程确认
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_PICK_LIST";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = s_org;
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = s_consignor;
                    command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                    command.Parameters["@sp_so"].Value = ds_so.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
                //出来修改波次的状态
                str_sql = "update " + g_usespace + ".so_ship_wave set confirm_day = convert(char(10),getdate(),102),confirmer='" + s_user + "',wave_status='2',main_dist='C',update_time=getdate(),updater='" + s_user + "' where " +
                          "inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and wave_no = '" + s_wave_no + "'";
                command.CommandType = CommandType.Text;
                command.CommandText = str_sql;
                SqldbCenter.ExecuteNonQuery(command);
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //定尺物料波次拣货确认
    [WebMethod]
    public string Sql_regular_wave_confirm(string s_org, string s_consignor, string s_wave_no, DataSet ds_confirm, string s_user)
    {
        return "";
    }

    //调用存储过程
    //拣货数量新增
    [WebMethod]
    public string Sql_exec_proc_pickadd(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat,string s_pallet,decimal d_qty, string s_user,string s_flag)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PICK_ADD");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.Char, 1);
            command.Parameters["@sp_flag"].Value = s_flag;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }


    //缺补货确认
    [WebMethod]
    public string Sql_exec_proc_shortpick(DataSet ds_data, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_data.Tables[0].Rows.Count > 0)
            { 
                for (int i = 0; i < ds_data.Tables[0].Rows.Count; i++)
                {
                    if (i > 0) command.Parameters.Clear();
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = g_usespace + ".SP_SQL_SHORT_PICK";
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_data.Tables[0].Rows[i]["sp_org"].ToString().Trim();
                    command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
                    command.Parameters["@sp_consignor"].Value = ds_data.Tables[0].Rows[i]["sp_consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_sono", SqlDbType.Char, 20);
                    command.Parameters["@sp_sono"].Value = ds_data.Tables[0].Rows[i]["sp_sono"].ToString().Trim();
                    command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                    command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_data.Tables[0].Rows[i]["sp_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                    command.Parameters["@sp_sku"].Value = ds_data.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                    command.Parameters.Add("@sp_location", SqlDbType.Char, 20);
                    command.Parameters["@sp_location"].Value = ds_data.Tables[0].Rows[i]["sp_location"].ToString().Trim();
                    command.Parameters.Add("@sp_batchno", SqlDbType.Char, 12);
                    command.Parameters["@sp_batchno"].Value = ds_data.Tables[0].Rows[i]["sp_batchno"].ToString().Trim();
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = ds_data.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                    command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                    command.Parameters["@sp_qty"].Precision = (byte)16;
                    command.Parameters["@sp_qty"].Scale = (byte)4;
                    command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_data.Tables[0].Rows[i]["sp_qty"].ToString().Trim());
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.Char, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //portal拣货数量新增
    [WebMethod]
    public string Sql_exec_proc_portalpick(string s_org, DataSet ds_portal, DataSet ds_box, string s_user, string s_flag)
    {
        string strsql;
        SqlCommand command;  
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //首先更新箱标在哪个拣货单
            if (ds_box.Tables[0].Rows.Count > 0) //说明有箱标存在
            {
                for (int i = 0; i < ds_box.Tables[0].Rows.Count; i++)
                {
                    strsql = "update " + g_usespace + ".inv_sku_rfid set so_no = '" + ds_box.Tables[0].Rows[i]["so_no"].ToString().Trim() + "',so_line_no=" + ds_box.Tables[0].Rows[i]["so_line_no"].ToString().Trim() +
                             " where inv_org = '"+s_org+"' and consignor = '" + ds_box.Tables[0].Rows[i]["consignor"].ToString().Trim() + "' and sku = '" + ds_box.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and box_rfid = '" +
                             ds_box.Tables[0].Rows[i]["box_rfid"].ToString().Trim() + "' and location_code = '" + ds_box.Tables[0].Rows[i]["location_code"].ToString().Trim() + "' and pallet_no = '" + ds_box.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "'"; ;
                    command.CommandType = CommandType.Text;
                    command.CommandText = strsql;
                    SqldbCenter.ExecuteNonQuery(command);
                }
            }
            for (int i = 0; i < ds_portal.Tables[0].Rows.Count; i++)
            { 
                command.Parameters.Clear();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_SQL_PICK_ADD";
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_portal.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                command.Parameters["@sp_so"].Value = ds_portal.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_portal.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_portal.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_portal.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                command.Parameters["@sp_bat"].Value = ds_portal.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_portal.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = Math.Round(System.Convert.ToDecimal(ds_portal.Tables[0].Rows[i]["stock_qty_m"].ToString().Trim()), 4);
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_flag", SqlDbType.Char, 1);
                command.Parameters["@sp_flag"].Value = s_flag;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //拣货数量修改
    [WebMethod]
    public string Sql_exec_proc_pickmodify(string s_org, DataSet ds_modify, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            decimal d_qty;
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_SQL_PICK_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                command.Parameters["@sp_so"].Value = ds_modify.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                command.Parameters["@sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batch_no"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = d_qty;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //拣货数量删除
    [WebMethod]
    public string Sql_exec_proc_pickdel(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat,string s_pallet,decimal d_qty, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PICK_DEL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //拣货数量取消
    [WebMethod]
    public string Sql_exec_proc_pickcancel(string s_org, DataSet ds_pick,string s_user)
    {
        string str_consignor, str_sono;
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_pick.Tables[0].Rows.Count; i++)
            {
                str_consignor = ds_pick.Tables[0].Rows[i]["consignor"].ToString().Trim();
                str_sono = ds_pick.Tables[0].Rows[i]["so_no"].ToString().Trim();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_SQL_PICK_CANCEL";
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = str_consignor;
                command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                command.Parameters["@sp_so"].Value = str_sono;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //拣货单生成 - 20250310 add
    [WebMethod]
    public string Sql_exec_proc_pickbillapply(string s_org, string s_consignor, string s_user)
    {
        LogHelpter.AddLog("【拣货单生成】存储过程SP_SQL_APPLY_PICKBILL 调用开始", null, null);

        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_APPLY_PICKBILL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            //command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            //command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        LogHelpter.AddLog("【拣货单生成】存储过程SP_SQL_APPLY_PICKBILL 调用结束 sp_out=" + str_ls_middle, null, null);        
        return str_ls_middle.Trim();
    }

    //发货确认
    [WebMethod]
    public string Sql_ship_confirm(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //然后调用存储过程确认
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_SQL_SHIP_CONFIRM";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                    command.Parameters["@sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货明细确认
    [WebMethod]
    public string Sql_ship_confirm_detail(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    if (dtst.Tables[0].Rows[i]["check1"].ToString().Trim() == "1")
                    {
                        if (System.Convert.ToDecimal(dtst.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim()) > 0)
                        {
                            command.CommandText = g_usespace + ".SP_SQL_SHIP_CONFIRM_DETAIL";
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                            command.Parameters["@sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                            command.Parameters["@sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                            command.Parameters["@sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                            command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(dtst.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                            command.Parameters["@sp_loc"].Value = dtst.Tables[0].Rows[i]["location_code"].ToString().Trim();
                            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                            command.Parameters["@sp_bat"].Value = dtst.Tables[0].Rows[i]["batchno"].ToString().Trim();
                            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                            command.Parameters["@sp_pallet"].Value = dtst.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                            command.Parameters["@sp_qty"].Precision = (byte)16;
                            command.Parameters["@sp_qty"].Scale = (byte)4;
                            command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(dtst.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                            command.Parameters["@sp_user"].Value = s_user;
                            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                            SqldbCenter.ExecuteNonQuery(command);
                            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                            {
                                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                                break;
                            }
                            command.Parameters.Clear();
                        }
                    }
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货明细取消
    [WebMethod]
    public string Sql_ship_cancel_detail(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_SQL_SHIP_CANCEL_DETAIL";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                    command.Parameters["@sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                    command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(dtst.Tables[0].Rows[i]["so_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_delivery_no", SqlDbType.Int);
                    command.Parameters["@sp_delivery_no"].Value = System.Convert.ToInt32(dtst.Tables[0].Rows[i]["delivery_line_no"].ToString().Trim());
                    command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                    command.Parameters["@sp_loc"].Value = dtst.Tables[0].Rows[i]["location_code"].ToString().Trim();
                    command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                    command.Parameters["@sp_bat"].Value = dtst.Tables[0].Rows[i]["batchno"].ToString().Trim();
                    command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                    command.Parameters["@sp_pallet"].Value = dtst.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                    command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 200);
                    command.Parameters["@sp_memo"].Value = dtst.Tables[0].Rows[i]["memo"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "1")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //发货取消
    [WebMethod] 
    public string Sql_ship_cancel(string s_org, string s_consignor, string s_so_no, string s_memo, string s_user)
    {  
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try  
        {  
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //调用存储过程确认
            command.CommandText = g_usespace + ".SP_SQL_SHIP_CANCEL";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 200);
            command.Parameters["@sp_memo"].Value = s_memo;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 256);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "1") //成功
            {
                SqldbCenter.Commit();
            }
            else  //失败
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //出库单关闭
    [WebMethod]
    public string Sql_so_close(DataSet dtst, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //然后调用存储过程确认
            if (dtst.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dtst.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_SQL_SO_CLOSE";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = dtst.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = dtst.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                    command.Parameters["@sp_so"].Value = dtst.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }  
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }  

    //强制补货做成
    [WebMethod]
    public string Sql_exec_proc_replecal(string s_org, string s_consignor, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLE_CAL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command); 
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //强制补货做成
    [WebMethod]
    public string Sql_exec_proc_replecal_new(string s_org, string s_consignor, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLE_CAL_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //补货单删除
    [WebMethod]
    public string Sql_exec_proc_repledelbill(string s_org, string s_consignor, string s_reple, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLE_DELBILL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_reple", SqlDbType.Char, 20);
            command.Parameters["@sp_reple"].Value = s_reple;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //补货明细单删除
    [WebMethod]
    public string Sql_exec_proc_repledel(string s_org, string s_consignor, string s_reple, int s_line, string s_loc, string s_bat, string s_pallet, string s_flag, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLE_DEL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_reple", SqlDbType.Char, 20);
            command.Parameters["@sp_reple"].Value = s_reple;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = s_line;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_flag", SqlDbType.Char, 2);
            command.Parameters["@sp_flag"].Value = s_flag;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "0") //成功
            {
                SqldbCenter.Commit();
            }
            else  //失败
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //判断修改或删除的拣货数据回到的库位是否有效
    [WebMethod]
    public string Sql_exec_proc_pickloc(string s_org, string s_consignor, string s_so_no, int i_lineno, string s_batch,string s_loc,string s_pallet)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PICK_LOC");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_lineno", SqlDbType.Int);
            command.Parameters["@sp_lineno"].Value = i_lineno;
            command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
            command.Parameters["@sp_batch"].Value = s_batch;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //判断修改或删除的拣货数据回到的库位是否有效
    [WebMethod]
    public string Sql_exec_proc_pickloclist(string s_org, string s_consignor, string s_so_no)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PICK_LOCLIST");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //出库单分单存储过程
    [WebMethod]
    public string Sql_exec_proc_billsplit(string s_org, string s_consignor, string s_eas_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_BILL_SPLIT");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_eas_no", SqlDbType.Char, 20);
            command.Parameters["@sp_eas_no"].Value = s_eas_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //新出库单分单存储过程
    [WebMethod]
    public string Sql_exec_proc_sosplit_new(string s_org, string s_consignor, string s_eas_no, string str_flag, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_SO_SPLIT_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_eas_no", SqlDbType.Char, 20);
            command.Parameters["@sp_eas_no"].Value = s_eas_no;
            command.Parameters.Add("@sp_split_flag", SqlDbType.Char, 1);
            command.Parameters["@sp_split_flag"].Value = str_flag;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }


    //新出库单分单存储过程
    [WebMethod]
    public string Sql_exec_proc_asnsplit_new(string s_org, string s_consignor, string s_order_no, string str_flag, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ASN_SPLIT_NEW");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_order_no", SqlDbType.Char, 20);
            command.Parameters["@sp_order_no"].Value = s_order_no;
            command.Parameters.Add("@sp_split_flag", SqlDbType.Char, 1);
            command.Parameters["@sp_split_flag"].Value = str_flag;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    #endregion
    #region 库存管理的函数(移动，调整，盘点，转移，冻结)
    //盘点差异做成调整单
    [WebMethod]
    public void Sql_exec_proc_chkadjust(string s_org, string s_checkno, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_MAKE_ADJUST");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_checkno", SqlDbType.Char, 20);
            command.Parameters["@sp_checkno"].Value = s_checkno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //批量更新盘点数据
    [WebMethod]
    public void Sql_refresh_checkdb(string s_org, DataSet dtst, string strsql, string s_checkno, string str_userid)
    {
        string s_str;
        int i_count;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            //判断盘点是否全部确认完成，如果是改状态是3，否则2
            s_str = "select count(*) from " + g_usespace + ".inv_check_detail where inv_org = '"+s_org+"' and check_no ='" + s_checkno + "' and check_status ='0'";
            command.CommandText = s_str;
            i_count = SqldbCenter.ExecuteScalar(command);
            s_str = "update " + g_usespace + ".inv_check_header set ";
            if (i_count > 0)//说明还没有收完
                s_str = s_str + "check_status = '2',";
            else
                s_str = s_str + "check_status = '3',";
            s_str = s_str + "main_dist = 'C',update_time=getdate(),updater='" + str_userid + "' where inv_org = '"+s_org+"' and check_no ='" + s_checkno + "'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //批量插入根据盘点差异生成的调整单,这个sql要先插入一个临时表所以要特别的写，oralce不需要
    [WebMethod]
    public void Sql_insert_checkadjust(string s_sql1, string s_sql2)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = s_sql1;
            SqldbCenter.ExecuteNonQuery(command);
            command.CommandText = s_sql2;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        } 
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;  
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //批量更新复核盘点数据
    [WebMethod]
    public void Sql_refresh_checkdb_review(string s_org, DataSet dtst, string strsql, string s_checkno, int i_number, string str_userid)
    {
        string s_str;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            //判断盘点是否全部确认完成，根据盘点次数更新盘点数量
            s_str = "update " + g_usespace + ".inv_check_detail set check_qty_m = isnull(a.check_qty_m,0),check_qty_s = isnull(a.check_qty_s,0),main_dist = 'C',updater = '" + str_userid + "',update_time = getdate() from " +
                    g_usespace + ".inv_check_detail_review a where " + g_usespace + ".inv_check_detail.inv_org = '" + s_org + "' and " + g_usespace + ".inv_check_detail.check_no ='" + s_checkno + "' " +
                    " and a.inv_org = " + g_usespace + ".inv_check_detail.inv_org " +
                    " and a.check_no = " + g_usespace + ".inv_check_detail.check_no and a.check_line_no = " + g_usespace + ".inv_check_detail.check_line_no " +
                    " and a.check_number = " + i_number.ToString().Trim() + " and a.check_status = '1'";
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();  
        }
    }

    //库存调整明细新增
    [WebMethod]
    public void Sql_add_adjdetail(string s_org, DataSet ds_adj, string str_userid)
    {
        string s_str;
        int i_adj_no;
        SqlCommand command; 
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try 
        { 
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //得到最大行号
            s_str = "select isnull(max(adjust_line_no),0) from " + g_usespace + ".inv_adjust_detail where inv_org = '"+s_org+"' and consignor = '" + ds_adj.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' " +
                    "and adjust_no ='" + ds_adj.Tables[0].Rows[0]["adjust_no"].ToString().Trim() + "'";
            command.CommandText = s_str;
            i_adj_no = SqldbCenter.ExecuteScalar(command);
            //循环进行调整明细新增 
            for (int i = 0; i < ds_adj.Tables[0].Rows.Count; i++)
            { 
                i_adj_no = i_adj_no + 1;     
                //插入调整明细
                s_str = "insert into " + g_usespace + ".inv_adjust_detail(inv_org,consignor,	adjust_no,	adjust_line_no,	batchno," +
                                                                        "sku,		sku_name,	main_sub_flag,	convert_modulus," +
                                                                        "location_code,	pallet_no,	from_stock_qty_m,	from_stock_qty_s," +
                                                                        "to_stock_qty_m,	to_stock_qty_s,	from_cubage,	from_gross_weight," +
                                                                        "from_net_weight,	to_cubage,	to_gross_weight,	to_net_weight," +
                                                                        "from_order_price,	from_unit,	to_order_price,	to_unit," +
                                                                        "adjust_status,	confirm_flag,	confirm_day,	confirmer," +
                                                                        "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                        "standby_5,	standby_6,	standby_7,	main_dist,   made_time,	maker," +
                                                                        "lot_attribute1,lot_attribute2,lot_attribute3,lot_attribute4,lot_attribute5," +
                                                                        "lot_attribute6,lot_attribute7,lot_attribute8,lot_attribute9,lot_attribute10," +
                                                                        "lot_attribute11,lot_attribute12,lot_attribute13,lot_attribute14,lot_attribute15)" +
                        "values('" + s_org + "','" + ds_adj.Tables[0].Rows[i]["consignor"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["adjust_no"].ToString().Trim() + "'," + System.Convert.ToString(i_adj_no) + ",'" + ds_adj.Tables[0].Rows[i]["batchno"].ToString().Trim() + "','" +
                        ds_adj.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["sku_name"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'," + ds_adj.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" +
                        ds_adj.Tables[0].Rows[i]["location_code"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["pallet_no"].ToString().Trim() + "'," + ds_adj.Tables[0].Rows[i]["from_stock_qty_m"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["from_stock_qty_s"].ToString().Trim() + "," +
                        ds_adj.Tables[0].Rows[i]["to_stock_qty_m"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_stock_qty_s"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["from_cubage"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["from_gross_weight"].ToString().Trim() + "," +
                        ds_adj.Tables[0].Rows[i]["from_net_weight"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_cubage"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_gross_weight"].ToString().Trim() + "," + ds_adj.Tables[0].Rows[i]["to_net_weight"].ToString().Trim() + "," +
                        ds_adj.Tables[0].Rows[i]["from_order_price"].ToString().Trim() + ",'" + ds_adj.Tables[0].Rows[i]["from_unit"].ToString().Trim() + "'," + ds_adj.Tables[0].Rows[i]["to_order_price"].ToString().Trim() + ",'" + ds_adj.Tables[0].Rows[i]["to_unit"].ToString().Trim() + "'," +
                        "'0','','','','','','','','',0,0,'A',getdate(),'" + str_userid + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim() + "'" +
                        ",'" + ds_adj.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim() + "'" +
                        ",'" + ds_adj.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim() + "','" + ds_adj.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim() + "')";
                command.CommandText = s_str;
                SqldbCenter.ExecuteNonQuery(command);
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }


    //调用存储过程
    //库存调整表头确认
    [WebMethod]
    public string Sql_exec_proc_adjconlist(string s_org, string s_consignor, string s_adjno, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ADJ_CON_LIST");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_customer", SqlDbType.Char, 15);
            command.Parameters["@sp_customer"].Value = s_consignor;
            command.Parameters.Add("@sp_adjustno", SqlDbType.Char, 20);
            command.Parameters["@sp_adjustno"].Value = s_adjno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_output", SqlDbType.VarChar, 50);
            command.Parameters["@sp_output"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_output"].Value.ToString().Trim();
    }

    //调用存储过程
    //库存调整明细确认
    [WebMethod]
    public string Sql_exec_proc_adjcon(string s_org, DataSet ds_adjcon,string s_user)
    {
        string s_consignor, s_adjno;
        int s_adjline;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_adjcon.Tables[0].Rows.Count; i++)
            {
                s_consignor = ds_adjcon.Tables[0].Rows[i]["consignor"].ToString().Trim();
                s_adjno = ds_adjcon.Tables[0].Rows[i]["adjust_no"].ToString().Trim();
                s_adjline = System.Convert.ToInt32(ds_adjcon.Tables[0].Rows[i]["adjust_line_no"].ToString().Trim());
                command.CommandText = g_usespace + ".SP_SQL_ADJ_CONFIRM";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_customer", SqlDbType.Char, 15);
                command.Parameters["@sp_customer"].Value = s_consignor;
                command.Parameters.Add("@sp_adjustno", SqlDbType.Char, 20);
                command.Parameters["@sp_adjustno"].Value = s_adjno;
                command.Parameters.Add("@sp_adjustline", SqlDbType.Int);
                command.Parameters["@sp_adjustline"].Value = s_adjline;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "")
                {
                    SqldbCenter.Rollback();
                    SqldbCenter.CloseConnection();
                    return command.Parameters["@sp_out"].Value.ToString().Trim();
                }
                command.Parameters.Clear(); 
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return "";
    }

    [WebMethod]
    public string Sql_exec_proc_adj_add_noinventery(DataSet ds_adjcon, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_adjcon.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_adjcon.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_SQL_ADJUST_ADD_NEW";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_adjcon.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_customer", SqlDbType.Char, 15);
                    command.Parameters["@sp_customer"].Value = ds_adjcon.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                    command.Parameters["@sp_sku"].Value = ds_adjcon.Tables[0].Rows[i]["sku"].ToString().Trim();
                    command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                    command.Parameters["@sp_pack"].Value = ds_adjcon.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                    command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                    command.Parameters["@sp_loc"].Value = ds_adjcon.Tables[0].Rows[i]["location_code"].ToString().Trim();
                    command.Parameters.Add("@sp_lot3", SqlDbType.Char, 20);
                    command.Parameters["@sp_lot3"].Value = ds_adjcon.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim();
                    command.Parameters.Add("@sp_lot5", SqlDbType.Char, 20);
                    command.Parameters["@sp_lot5"].Value = ds_adjcon.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = s_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //实时盘点调整单做成
    [WebMethod]
    public string Sql_exec_proc_checktimely_makeadjust(string s_org, string s_checkno, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_CKTIMELY_MAKE_ADJUST");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_checkno", SqlDbType.Char, 20);
            command.Parameters["@sp_checkno"].Value = s_checkno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 200);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }  
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //调用存储过程
    //库存冻结生成
    [WebMethod]
    public void Sql_exec_proc_makefreeze(string s_org, DataSet ds_freeze, string s_user)
    {
        string s_consignor,s_sku,s_pack,s_location,s_pallet,s_type,s_reason;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_freeze.Tables[0].Rows.Count; i++) 
            {
                s_consignor = ds_freeze.Tables[0].Rows[i]["consignor"].ToString().Trim();
                s_sku = ds_freeze.Tables[0].Rows[i]["sku"].ToString().Trim(); 
                s_location = ds_freeze.Tables[0].Rows[i]["location_code"].ToString().Trim();
                s_pallet = ds_freeze.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                s_type = ds_freeze.Tables[0].Rows[i]["freeze_type"].ToString().Trim();
                s_reason = ds_freeze.Tables[0].Rows[i]["freeze_reason"].ToString().Trim();
                s_pack = ds_freeze.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.CommandText = g_usespace + ".SP_SQL_FREEZE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_customer", SqlDbType.Char, 15);
                command.Parameters["@sp_customer"].Value = s_consignor;
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = s_sku;
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 20);
                command.Parameters["@sp_pack"].Value = s_pack;
                command.Parameters.Add("@sp_location", SqlDbType.Char,20);
                command.Parameters["@sp_location"].Value = s_location;
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = s_pallet;
                command.Parameters.Add("@sp_type", SqlDbType.Char, 1);
                command.Parameters["@sp_type"].Value = s_type; 
                command.Parameters.Add("@sp_reason", SqlDbType.Char, 2);
                command.Parameters["@sp_reason"].Value = s_reason;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                SqldbCenter.ExecuteNonQuery(command);
                command.Parameters.Clear();
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //库存解冻
    [WebMethod]
    public void Sql_exec_proc_unfreeze(string s_org, string s_consignor, string s_freeze, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_SQL_UNFREEZE";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_customer", SqlDbType.Char, 15);
            command.Parameters["@sp_customer"].Value = s_consignor;
            command.Parameters.Add("@sp_freezeno", SqlDbType.Char, 20);
            command.Parameters["@sp_freezeno"].Value = s_freeze;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //正大富通三包移库建议库位计算
    [WebMethod]
    public string Sql_move_calloc_new(string s_org, string s_consignor, decimal d_qtym, string s_sku, string s_pack, string s_box, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_SQL_MOVE_CAL_NEW";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qtym;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
            command.Parameters["@sp_pack"].Value = s_pack;
            command.Parameters.Add("@sp_box", SqlDbType.Char, 30);
            command.Parameters["@sp_box"].Value = s_box;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 100);
            command.Parameters["@sp_loc"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        } 
        catch (System.Exception)
        { 
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_loc"].Value.ToString().Trim();
    }

    //移库确认
    [WebMethod]
    public string Sql_move_confirm(string s_org, DataSet dtst, string strsql, string s_consignor, string s_move_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_SQL_MOVE_CONFIRM";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
            command.Parameters["@sp_moveno"].Value = s_move_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "0")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //移库数量新增
    [WebMethod]
    public string Sql_exec_proc_moveadd(string s_org, string s_consignor, string s_move_no, int i_line, string s_outloc, string s_inloc, string s_pallet, string s_ipallet, string s_bat, decimal d_qty, decimal d_pallet_qty, string s_outware, string s_inware, string s_user, string s_flag)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_MOVE_ADD");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
            command.Parameters["@sp_moveno"].Value = s_move_no;
            command.Parameters.Add("@sp_lineon", SqlDbType.Int);
            command.Parameters["@sp_lineon"].Value = i_line;
            command.Parameters.Add("@sp_moveout", SqlDbType.Char, 20);
            command.Parameters["@sp_moveout"].Value = s_outloc;
            command.Parameters.Add("@sp_movein", SqlDbType.Char, 20);
            command.Parameters["@sp_movein"].Value = s_inloc;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_inpallet", SqlDbType.Char, 15);
            command.Parameters["@sp_inpallet"].Value = s_ipallet;
            command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
            command.Parameters["@sp_batch"].Value = s_bat;
            command.Parameters.Add("@sp_use_qty", SqlDbType.Decimal);
            command.Parameters["@sp_use_qty"].Precision = (byte)16;
            command.Parameters["@sp_use_qty"].Scale = (byte)4;
            command.Parameters["@sp_use_qty"].Value = d_qty;
            command.Parameters.Add("@sp_pallet_qtym", SqlDbType.Decimal);
            command.Parameters["@sp_pallet_qtym"].Precision = (byte)16;  
            command.Parameters["@sp_pallet_qtym"].Scale = (byte)4;
            command.Parameters["@sp_pallet_qtym"].Value = d_pallet_qty;
            command.Parameters.Add("@sp_outloc", SqlDbType.Char, 5);
            command.Parameters["@sp_outloc"].Value = s_outware;
            command.Parameters.Add("@sp_inloc", SqlDbType.Char, 5);
            command.Parameters["@sp_inloc"].Value = s_inware;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.Char, 1);
            command.Parameters["@sp_flag"].Value = s_flag;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "0")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }
    
    //调用存储过程
    //移库数量修改
    [WebMethod]
    public void Sql_exec_proc_movemodify(string s_org, DataSet ds_modify, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            decimal d_qty;
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_SQL_MOVE_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_move_no", SqlDbType.Char, 20);
                command.Parameters["@sp_move_no"].Value = ds_modify.Tables[0].Rows[i]["move_no"].ToString().Trim();
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["move_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                command.Parameters["@sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batch_no"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_in_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_in_pallet"].Value = ds_modify.Tables[0].Rows[i]["in_pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = d_qty;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                SqldbCenter.ExecuteNonQuery(command);
                command.Parameters.Clear();
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //移库数量删除
    [WebMethod]
    public void Sql_exec_proc_movedel(string s_org, string s_consignor, string s_move_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_MOVE_DEL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_move_no", SqlDbType.Char, 20);
            command.Parameters["@sp_move_no"].Value = s_move_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //移库单关闭
    [WebMethod]
    public void Sql_exec_proc_moveclose(string s_org, string s_consignor, string s_move_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_MOVE_COLSE");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
            command.Parameters["@sp_moveno"].Value = s_move_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //补货确认
    [WebMethod]
    public string Sql_reple_confirm(string s_org, DataSet dtst, string strsql, string s_consignor, string s_move_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, dtst);
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_SQL_REPLEN_CONFIRM";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
            command.Parameters["@sp_moveno"].Value = s_move_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "0")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //补货数量新增
    [WebMethod]
    public string Sql_exec_proc_repleadd(string s_org, string s_consignor, string s_move_no, int i_line, string s_outloc, string s_inloc, string s_pallet,string s_ipallet, string s_bat, decimal d_qty, decimal d_pallet_qty, string s_user, string s_flag)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLEN_ADD");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
            command.Parameters["@sp_moveno"].Value = s_move_no;
            command.Parameters.Add("@sp_lineon", SqlDbType.Int);
            command.Parameters["@sp_lineon"].Value = i_line;
            command.Parameters.Add("@sp_moveout", SqlDbType.Char, 20);
            command.Parameters["@sp_moveout"].Value = s_outloc;
            command.Parameters.Add("@sp_movein", SqlDbType.Char, 20);
            command.Parameters["@sp_movein"].Value = s_inloc;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_inpallet", SqlDbType.Char, 15);
            command.Parameters["@sp_inpallet"].Value = s_ipallet;
            command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
            command.Parameters["@sp_batch"].Value = s_bat; 
            command.Parameters.Add("@sp_use_qty", SqlDbType.Decimal);
            command.Parameters["@sp_use_qty"].Precision = (byte)16;
            command.Parameters["@sp_use_qty"].Scale = (byte)4;
            command.Parameters["@sp_use_qty"].Value = d_qty;
            command.Parameters.Add("@sp_pallet_qtym", SqlDbType.Decimal);
            command.Parameters["@sp_pallet_qtym"].Precision = (byte)16;
            command.Parameters["@sp_pallet_qtym"].Scale = (byte)4;
            command.Parameters["@sp_pallet_qtym"].Value = d_pallet_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.Char, 1);
            command.Parameters["@sp_flag"].Value = s_flag;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "0")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //补货数量修改
    [WebMethod]
    public void Sql_exec_proc_replemodify(string s_org, DataSet ds_modify, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            decimal d_qty;
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_modify.Tables[0].Rows.Count; i++)
            {
                d_qty = Math.Round(System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["old_qty"].ToString().Trim()) - System.Convert.ToDecimal(ds_modify.Tables[0].Rows[i]["qty"].ToString().Trim()), 4);
                command.CommandText = g_usespace + ".SP_SQL_REPLEN_MODIFY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_modify.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_move_no", SqlDbType.Char, 20);
                command.Parameters["@sp_move_no"].Value = ds_modify.Tables[0].Rows[i]["move_no"].ToString().Trim();
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_modify.Tables[0].Rows[i]["move_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_modify.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_modify.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
                command.Parameters["@sp_bat"].Value = ds_modify.Tables[0].Rows[i]["batch_no"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_modify.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_in_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_in_pallet"].Value = ds_modify.Tables[0].Rows[i]["in_pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = d_qty;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                SqldbCenter.ExecuteNonQuery(command);
                command.Parameters.Clear();
            }
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //调用存储过程
    //移库数量删除
    [WebMethod]
    public void Sql_exec_proc_repledelete(string s_org, string s_consignor, string s_move_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLEN_DEL");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_move_no", SqlDbType.Char, 20);
            command.Parameters["@sp_move_no"].Value = s_move_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }

    //转移确认
    [WebMethod]
    public string Sql_exec_proc_transfer(string s_org, DataSet ds_transfer, string s_user)
    {
        string str_sql;
        string str_ls_middle;
        int tmp_page;
        string str_tr_no;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = ""; 
        try
        {  
            //得到单据号
            tmp_page = Sql_get_accountno(s_org, "TRANS_NO");
            str_tr_no = "TR" + tmp_page.ToString().PadLeft(8, '0').Trim();
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //首先插入表头信息
            str_sql = "insert into " + g_usespace + ".inv_transfer_header(inv_org,	transfer_no,	transfer_type,	transfer_reason," +
                                                                    "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                    "standby_5,	standby_6,	standby_7,	transfer_status," +
                                                                    "memo,		main_dist,	made_time,	maker)" +
                                                        " values ('" + s_org + "','" + str_tr_no + "','0',''," +
                                                                 "'','','',''," +
                                                                 "'',0,0,'1'," +
                                                                 "'','A',getdate(),'" + s_user + "')";
            command.CommandType = CommandType.Text;
            command.CommandText = str_sql;
            SqldbCenter.ExecuteNonQuery(command);
            //循环进行库存转移
            for (int i = 0; i < ds_transfer.Tables[0].Rows.Count; i++)
            {
                //在执行存储过程
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = g_usespace + ".SP_SQL_TRANSFER";
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_transfer_no", SqlDbType.Char, 20);
                command.Parameters["@sp_transfer_no"].Value = str_tr_no;
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = i + 1;
                command.Parameters.Add("@sp_batchno", SqlDbType.Char, 12);
                command.Parameters["@sp_batchno"].Value = ds_transfer.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_transfer.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_transfer.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_lottrs", SqlDbType.Char, 315);
                command.Parameters["@sp_lottrs"].Value = ds_transfer.Tables[0].Rows[i]["str_lottrs"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_transfer.Tables[0].Rows[i]["trans_qty_m"].ToString().Trim());
                command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 200);
                command.Parameters["@sp_memo"].Value = ds_transfer.Tables[0].Rows[i]["memo"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                    command.Parameters.Clear();
                    break;
                }
                command.Parameters.Clear();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            } 
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //江森转移确认
    [WebMethod]
    public string Sql_exec_proc_transfer_js(string s_org, string[] s_sql, string s_consignor, string s_trans_no, string s_newpack, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();//(g_usespace + ".SP_SQL_ALLOC_MODIFY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";   
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //先保存数据
            for (int i = 0; i < s_sql.Length; i++)
            {
                if (s_sql[i].ToString().Trim() != "")
                {
                    command.CommandText = s_sql[i].ToString().Trim();
                    SqldbCenter.ExecuteNonQuery(command);
                }
            }
            //在执行存储过程
            command.CommandText = g_usespace + ".SP_SQL_TRANSFER";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_tra", SqlDbType.Char, 20);
            command.Parameters["@sp_tra"].Value = s_trans_no;
            command.Parameters.Add("@sp_pack", SqlDbType.Char, 20);
            command.Parameters["@sp_pack"].Value = s_newpack;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                SqldbCenter.Rollback();
            }
            else
            {
                SqldbCenter.Commit();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //判断移库的库位是否有效
    [WebMethod]
    public string Sql_exec_proc_moveloc(string s_org, string s_consignor, string s_sku, string s_oloc, string s_iloc,decimal d_qty,string s_pack)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_CHECK_LOC");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_outloc", SqlDbType.Char, 20);
            command.Parameters["@sp_outloc"].Value = s_oloc;
            command.Parameters.Add("@sp_inloc", SqlDbType.Char, 20);
            command.Parameters["@sp_inloc"].Value = s_iloc;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qty;
            command.Parameters.Add("@sp_pack", SqlDbType.Char, 20);
            command.Parameters["@sp_pack"].Value = s_pack;
            command.Parameters.Add("@sp_putloc", SqlDbType.VarChar, 50);
            command.Parameters["@sp_putloc"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_putloc"].Value.ToString().Trim();
    }

    //portal生成盘点数据
    [WebMethod]
    public string Sql_exec_proc_portalcheck(string s_org, string s_loc1, string s_loc2, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PORTAL_CHECK");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_loc1", SqlDbType.Char, 20);
            command.Parameters["@sp_loc1"].Value = s_loc1;
            command.Parameters.Add("@sp_loc2", SqlDbType.Char, 20);
            command.Parameters["@sp_loc2"].Value = s_loc2; 
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
            //         return command.Parameters["sp_out"].Value.ToString().Trim();
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //临时领料的存储过程
    [WebMethod]
    public string Sql_exec_proc_tempupdate(DataSet ds_tempupdate, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_tempupdate.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_TEMP_UPDATE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_org"].ToString().Trim();
                command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
                command.Parameters["@sp_consignor"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_consignor"].ToString().Trim();
                command.Parameters.Add("@sp_tkno", SqlDbType.Char, 20);
                command.Parameters["@sp_tkno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_tkno"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("@sp_location", SqlDbType.Char, 20);
                command.Parameters["@sp_location"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_location"].ToString().Trim();
                command.Parameters.Add("@sp_batchno", SqlDbType.Char, 12);
                command.Parameters["@sp_batchno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_batchno"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_tempupdate.Tables[0].Rows[i]["sp_qty"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 200);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
            }
            SqldbCenter.Commit();  
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //快速出库的存储过程
    [WebMethod]
    public string Sql_exec_proc_quickout(DataSet ds_tempupdate, string s_user)
    {
        string str_ls_middle;
        str_ls_middle = "";
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_tempupdate.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_QUICKOUT";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_org"].ToString().Trim();
                command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
                command.Parameters["@sp_consignor"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_consignor"].ToString().Trim();
                command.Parameters.Add("@sp_tkno", SqlDbType.Char, 20);
                command.Parameters["@sp_tkno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_tkno"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("@sp_location", SqlDbType.Char, 20);
                command.Parameters["@sp_location"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_location"].ToString().Trim();
                command.Parameters.Add("@sp_batchno", SqlDbType.Char, 12);
                command.Parameters["@sp_batchno"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_batchno"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_tempupdate.Tables[0].Rows[i]["sp_qty"].ToString().Trim());
                command.Parameters.Add("@sp_reason", SqlDbType.VarChar, 200);
                command.Parameters["@sp_reason"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_reason"].ToString().Trim();
                command.Parameters.Add("@sp_customer", SqlDbType.VarChar, 100);
                command.Parameters["@sp_customer"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_customer"].ToString().Trim();
                command.Parameters.Add("@sp_equipment", SqlDbType.VarChar, 30);
                command.Parameters["@sp_equipment"].Value = ds_tempupdate.Tables[0].Rows[i]["sp_equipment"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 200);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "1")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //委外出库确认的存储过程
    [WebMethod]
    public string Sql_exec_proc_dpout(string s_org, DataSet ds_dpout, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_dpout.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_DP_OUT";
                command.CommandType = CommandType.StoredProcedure; 
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_dpout.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_dp", SqlDbType.Char, 20);
                command.Parameters["@sp_dp"].Value = ds_dpout.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                command.Parameters["@sp_line_no"].Value = System.Convert.ToInt32(ds_dpout.Tables[0].Rows[i]["dp_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
                command.Parameters["@sp_batch"].Value = ds_dpout.Tables[0].Rows[i]["batchno"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_dpout.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_dpout.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_dpout.Tables[0].Rows[i]["con_qty"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //委外入库确认的存储过程
    [WebMethod]
    public string Sql_exec_proc_dpin(string s_org, DataSet ds_dpuse, DataSet ds_dpin, string s_user)
    {
        string str_lot;
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////委外用料的存储过程
            for (int i = 0; i < ds_dpuse.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_DP_USE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_dpuse.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
                command.Parameters["@sp_in"].Value = ds_dpuse.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("@sp_dp", SqlDbType.Char, 20);
                command.Parameters["@sp_dp"].Value = ds_dpuse.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_dpuse.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_pack"].Value = ds_dpuse.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_dpuse.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal); 
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_dpuse.Tables[0].Rows[i]["use_qty"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }

            /////委外入库的存储过程
            str_lot = "";
            for (int i = 0; i < ds_dpin.Tables[0].Rows.Count; i++)
            {
                command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_DP_INPUT";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_dpin.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
                command.Parameters["@sp_in"].Value = ds_dpin.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_dpin.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_dpin.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_dpin.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_pack"].Value = ds_dpin.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("@sp_qty_s", SqlDbType.Decimal);
                command.Parameters["@sp_qty_s"].Precision = (byte)16;
                command.Parameters["@sp_qty_s"].Scale = (byte)4;
                command.Parameters["@sp_qty_s"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("@sp_cubage", SqlDbType.Decimal);
                command.Parameters["@sp_cubage"].Precision = (byte)10;
                command.Parameters["@sp_cubage"].Scale = (byte)4;
                command.Parameters["@sp_cubage"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_cubage"].ToString().Trim());
                command.Parameters.Add("@sp_gross", SqlDbType.Decimal);
                command.Parameters["@sp_gross"].Precision = (byte)10; 
                command.Parameters["@sp_gross"].Scale = (byte)4;
                command.Parameters["@sp_gross"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_gross_weight"].ToString().Trim());
                command.Parameters.Add("@sp_net", SqlDbType.Decimal);
                command.Parameters["@sp_net"].Precision = (byte)10;
                command.Parameters["@sp_net"].Scale = (byte)4;
                command.Parameters["@sp_net"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_net_weight"].ToString().Trim());
                //处理批次属性 
                str_lot = ds_dpin.Tables[0].Rows[i]["lot_attribute1"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute2"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute4"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute7"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute8"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute9"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute10"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute11"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute12"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute13"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute14"].ToString().Trim();
                str_lot = str_lot + ";" + ds_dpin.Tables[0].Rows[i]["lot_attribute15"].ToString().Trim();
                command.Parameters.Add("@sp_lot", SqlDbType.VarChar, 300);
                command.Parameters["@sp_lot"].Value = str_lot;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //卷钢开卷的存储过程
    [WebMethod]
    public string Sql_exec_proc_coiling(string s_org, DataSet ds_dpuse, DataSet ds_dpin, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////委外用料的存储过程
            for (int i = 0; i < ds_dpuse.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_DP_USE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_dpuse.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
                command.Parameters["@sp_in"].Value = ds_dpuse.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("@sp_dp", SqlDbType.Char, 20);
                command.Parameters["@sp_dp"].Value = ds_dpuse.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_dpuse.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_pack"].Value = ds_dpuse.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_dpuse.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_dpuse.Tables[0].Rows[i]["use_qty"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }

            /////委外入库的存储过程
            for (int i = 0; i < ds_dpin.Tables[0].Rows.Count; i++)
            {
                command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_DP_COILING";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_dpin.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
                command.Parameters["@sp_in"].Value = ds_dpin.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_dpin.Tables[0].Rows[i]["location_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_dpin.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_dpin.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_pack"].Value = ds_dpin.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("@sp_qty_s", SqlDbType.Decimal);
                command.Parameters["@sp_qty_s"].Precision = (byte)16;
                command.Parameters["@sp_qty_s"].Scale = (byte)4;
                command.Parameters["@sp_qty_s"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("@sp_cubage", SqlDbType.Decimal);
                command.Parameters["@sp_cubage"].Precision = (byte)10;
                command.Parameters["@sp_cubage"].Scale = (byte)4;
                command.Parameters["@sp_cubage"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_cubage"].ToString().Trim());
                command.Parameters.Add("@sp_gross", SqlDbType.Decimal);
                command.Parameters["@sp_gross"].Precision = (byte)10;
                command.Parameters["@sp_gross"].Scale = (byte)4;
                command.Parameters["@sp_gross"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_gross_weight"].ToString().Trim());
                command.Parameters.Add("@sp_net", SqlDbType.Decimal);
                command.Parameters["@sp_net"].Precision = (byte)10;
                command.Parameters["@sp_net"].Scale = (byte)4;
                command.Parameters["@sp_net"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["confirm_net_weight"].ToString().Trim());
                command.Parameters.Add("@sp_lot3", SqlDbType.VarChar, 20);
                command.Parameters["@sp_lot3"].Value = ds_dpin.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim();
                command.Parameters.Add("@sp_lot5", SqlDbType.VarChar, 20);
                command.Parameters["@sp_lot5"].Value = ds_dpin.Tables[0].Rows[i]["lot_attribute5"].ToString().Trim();
                command.Parameters.Add("@sp_coil_left", SqlDbType.Decimal);
                command.Parameters["@sp_coil_left"].Precision = (byte)10;
                command.Parameters["@sp_coil_left"].Scale = (byte)4;
                command.Parameters["@sp_coil_left"].Value = System.Convert.ToDecimal(ds_dpin.Tables[0].Rows[i]["coil_left"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //委外计划入库确认的存储过程
    [WebMethod]
    public string Sql_exec_proc_plandpin(string s_org, DataSet ds_dpuse, DataSet ds_dpin, string strsql, string s_consignor, string s_in_no, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = strsql;
            SqldbCenter.updatedatabaser(command, ds_dpin);
            /////委外用料的存储过程
            for (int i = 0; i < ds_dpuse.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_DP_USE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_dpuse.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
                command.Parameters["@sp_in"].Value = ds_dpuse.Tables[0].Rows[i]["in_no"].ToString().Trim();
                command.Parameters.Add("@sp_dp", SqlDbType.Char, 20);
                command.Parameters["@sp_dp"].Value = ds_dpuse.Tables[0].Rows[i]["dp_no"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_dpuse.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_pack"].Value = ds_dpuse.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_dpuse.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_dpuse.Tables[0].Rows[i]["use_qty"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            command.Parameters.Clear();
            /////委外入库的存储过程
            //然后调用存储过程确认
            command.CommandText = g_usespace + ".SP_SQL_DP_PLANIN";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
            command.Parameters["@sp_in"].Value = s_in_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally  
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //委外出库冲单的存储过程
    [WebMethod]
    public string Sql_exec_proc_dpredbill(string s_org, string s_consignor, string s_no, string s_ori_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_DP_REDBILLOUT");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_dp", SqlDbType.Char, 20);
            command.Parameters["@sp_dp"].Value = s_no;
            command.Parameters.Add("@sp_ori_dp", SqlDbType.Char, 20);
            command.Parameters["@sp_ori_dp"].Value = s_ori_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //委外入库冲单的存储过程
    [WebMethod]
    public string Sql_exec_proc_inredbill(string s_org, string s_consignor, string s_in, string s_ori_in, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_DP_REDBILLIN");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_in", SqlDbType.Char, 20);
            command.Parameters["@sp_in"].Value = s_in;
            command.Parameters.Add("@sp_ori_in", SqlDbType.Char, 20);
            command.Parameters["@sp_ori_in"].Value = s_ori_in;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 10);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //质检确认存储过程
    [WebMethod]
    public string Sql_exec_proc_qcconfirm(DataSet ds_qcconfirm, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_QC_CONFIRM";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
                command.Parameters["@sp_asnno"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_recno", SqlDbType.Int);
                command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty_m", SqlDbType.Decimal);
                command.Parameters["@sp_qty_m"].Precision = (byte)16;
                command.Parameters["@sp_qty_m"].Scale = (byte)4;
                command.Parameters["@sp_qty_m"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("@sp_qty_s", SqlDbType.Decimal);
                command.Parameters["@sp_qty_s"].Precision = (byte)16;
                command.Parameters["@sp_qty_s"].Scale = (byte)4;
                command.Parameters["@sp_qty_s"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("@sp_cubage", SqlDbType.Decimal);
                command.Parameters["@sp_cubage"].Precision = (byte)10;
                command.Parameters["@sp_cubage"].Scale = (byte)4;
                command.Parameters["@sp_cubage"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_cubage"].ToString().Trim());
                command.Parameters.Add("@sp_gross", SqlDbType.Decimal);
                command.Parameters["@sp_gross"].Precision = (byte)10;
                command.Parameters["@sp_gross"].Scale = (byte)4;
                command.Parameters["@sp_gross"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_gross_weight"].ToString().Trim());
                command.Parameters.Add("@sp_net", SqlDbType.Decimal);
                command.Parameters["@sp_net"].Precision = (byte)10;
                command.Parameters["@sp_net"].Scale = (byte)4;
                command.Parameters["@sp_net"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_net_weight"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                //command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 200);
                //command.Parameters["@sp_memo"].Value = ds_qcconfirm.Tables[0].Rows[i]["memo"].ToString().Trim();
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 256);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //质检确认存储过程
    [WebMethod]
    public string Sql_exec_proc_qcconfirm_new(DataSet ds_qcconfirm, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_QC_CONFIRM_NEW";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
                command.Parameters["@sp_asnno"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_recno", SqlDbType.Int);
                command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty_m", SqlDbType.Decimal);
                command.Parameters["@sp_qty_m"].Precision = (byte)16;
                command.Parameters["@sp_qty_m"].Scale = (byte)4;
                command.Parameters["@sp_qty_m"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("@sp_qty_s", SqlDbType.Decimal);
                command.Parameters["@sp_qty_s"].Precision = (byte)16;
                command.Parameters["@sp_qty_s"].Scale = (byte)4;
                command.Parameters["@sp_qty_s"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_s"].ToString().Trim());
                command.Parameters.Add("@sp_cubage", SqlDbType.Decimal);
                command.Parameters["@sp_cubage"].Precision = (byte)10;
                command.Parameters["@sp_cubage"].Scale = (byte)4;
                command.Parameters["@sp_cubage"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_cubage"].ToString().Trim());
                command.Parameters.Add("@sp_gross", SqlDbType.Decimal);
                command.Parameters["@sp_gross"].Precision = (byte)10;
                command.Parameters["@sp_gross"].Scale = (byte)4;
                command.Parameters["@sp_gross"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_gross_weight"].ToString().Trim());
                command.Parameters.Add("@sp_net", SqlDbType.Decimal);
                command.Parameters["@sp_net"].Precision = (byte)10;
                command.Parameters["@sp_net"].Scale = (byte)4;
                command.Parameters["@sp_net"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["qc_net_weight"].ToString().Trim());
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_memo", SqlDbType.VarChar, 200);
                command.Parameters["@sp_memo"].Value = ds_qcconfirm.Tables[0].Rows[i]["memo"].ToString().Trim();
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 256);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //质检上架计算的存储过程
    [WebMethod]
    public string Sql_exec_proc_qcputaway(DataSet ds_qcconfirm, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_QC_PUTAWAY";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                command.Parameters["@sp_asn"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_recno", SqlDbType.Int);
                command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
                command.Parameters["@sp_qty"].Precision = (byte)16;
                command.Parameters["@sp_qty"].Scale = (byte)4;
                command.Parameters["@sp_qty"].Value = System.Convert.ToDecimal(ds_qcconfirm.Tables[0].Rows[i]["confirm_qty_m"].ToString().Trim());
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_qcconfirm.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_pack"].Value = ds_qcconfirm.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_loc", SqlDbType.VarChar, 256);
                command.Parameters["@sp_loc"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_loc"].Value.ToString().Trim().ToUpper().Substring(0, 3) == "ERR")
                {
                    str_ls_middle = command.Parameters["@sp_loc"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //质检上架确认的存储过程
    [WebMethod]
    public string Sql_exec_proc_qcpaconfirm(DataSet ds_qcconfirm, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_qcconfirm.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_QCPA_CONFIRM";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_qcconfirm.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_qcconfirm.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                command.Parameters["@sp_asn"].Value = ds_qcconfirm.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                command.Parameters["@sp_lineno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["asn_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_recno", SqlDbType.Int);
                command.Parameters["@sp_recno"].Value = System.Convert.ToInt32(ds_qcconfirm.Tables[0].Rows[i]["receive_line_no"].ToString().Trim());
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_qcconfirm.Tables[0].Rows[i]["pallet_no"].ToString().Trim();
                command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                command.Parameters["@sp_loc"].Value = ds_qcconfirm.Tables[0].Rows[i]["fact_location"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
                command.Parameters["@sp_method"].Value = "1";
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 256);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();  
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //移库指令新增
    [WebMethod]
    public string Sql_exec_proc_moveadd_header(string s_org, string s_consignor, string s_moveno, DataSet ds_move, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_move.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_MOVE_ADD_ORDER";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
                command.Parameters["@sp_consignor"].Value = s_consignor;
                command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
                command.Parameters["@sp_moveno"].Value = s_moveno;
                command.Parameters.Add("@sp_lineon", SqlDbType.Int);
                command.Parameters["@sp_lineon"].Value = System.Convert.ToInt32(ds_move.Tables[0].Rows[i]["sp_lineon"].ToString().Trim());
                command.Parameters.Add("@sp_warehouseout", SqlDbType.Char, 5);
                command.Parameters["@sp_warehouseout"].Value = ds_move.Tables[0].Rows[i]["sp_warehouseout"].ToString().Trim();
                command.Parameters.Add("@sp_warehousein", SqlDbType.Char, 5);
                command.Parameters["@sp_warehousein"].Value = ds_move.Tables[0].Rows[i]["sp_warehousein"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
                command.Parameters["@sp_batch"].Value = ds_move.Tables[0].Rows[i]["sp_batch"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_move.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("@sp_use_qty", SqlDbType.Decimal);
                command.Parameters["@sp_use_qty"].Precision = (byte)16;
                command.Parameters["@sp_use_qty"].Scale = (byte)4;
                command.Parameters["@sp_use_qty"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty"].ToString().Trim());
                command.Parameters.Add("@sp_outloc", SqlDbType.Char, 20);
                command.Parameters["@sp_outloc"].Value = ds_move.Tables[0].Rows[i]["sp_outloc"].ToString().Trim();
                command.Parameters.Add("@sp_inloc", SqlDbType.Char, 20);
                command.Parameters["@sp_inloc"].Value = ds_move.Tables[0].Rows[i]["sp_inloc"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //移库指令删除
    [WebMethod]
    public string Sql_exec_proc_movedel_header(string s_org, string s_consignor, string s_moveno, DataSet ds_move, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_move.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_MOVE_DELETE_ORDER";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
                command.Parameters["@sp_consignor"].Value = s_consignor;
                command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
                command.Parameters["@sp_moveno"].Value = s_moveno;
                command.Parameters.Add("@sp_lineon", SqlDbType.Int);
                command.Parameters["@sp_lineon"].Value = System.Convert.ToInt32(ds_move.Tables[0].Rows[i]["sp_lineon"].ToString().Trim());
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("@sp_in_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_in_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_in_pallet"].ToString().Trim();
                command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
                command.Parameters["@sp_batch"].Value = ds_move.Tables[0].Rows[i]["sp_batch"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_move.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("@sp_use_qty", SqlDbType.Decimal);
                command.Parameters["@sp_use_qty"].Precision = (byte)16;
                command.Parameters["@sp_use_qty"].Scale = (byte)4;
                command.Parameters["@sp_use_qty"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty"].ToString().Trim());
                command.Parameters.Add("@sp_use_qty_s", SqlDbType.Decimal);
                command.Parameters["@sp_use_qty_s"].Precision = (byte)16;
                command.Parameters["@sp_use_qty_s"].Scale = (byte)4;
                command.Parameters["@sp_use_qty_s"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty_s"].ToString().Trim());
                command.Parameters.Add("@sp_outloc", SqlDbType.Char, 20);
                command.Parameters["@sp_outloc"].Value = ds_move.Tables[0].Rows[i]["sp_outloc"].ToString().Trim();
                command.Parameters.Add("@sp_inloc", SqlDbType.Char, 20);
                command.Parameters["@sp_inloc"].Value = ds_move.Tables[0].Rows[i]["sp_inloc"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //移库指令修改
    [WebMethod]
    public string Sql_exec_proc_movemodify_header(string s_org, string s_consignor, string s_moveno, DataSet ds_move, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            /////质检确认的存储过程
            for (int i = 0; i < ds_move.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_MOVE_MODIFY_ORDER";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_org;
                command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
                command.Parameters["@sp_consignor"].Value = s_consignor;
                command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
                command.Parameters["@sp_moveno"].Value = s_moveno;
                command.Parameters.Add("@sp_lineon", SqlDbType.Int);
                command.Parameters["@sp_lineon"].Value = System.Convert.ToInt32(ds_move.Tables[0].Rows[i]["sp_lineon"].ToString().Trim());
                command.Parameters.Add("@sp_warehousein", SqlDbType.Char, 5);
                command.Parameters["@sp_warehousein"].Value = ds_move.Tables[0].Rows[i]["sp_warehousein"].ToString().Trim();
                command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                command.Parameters["@sp_pallet"].Value = ds_move.Tables[0].Rows[i]["sp_pallet"].ToString().Trim();
                command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
                command.Parameters["@sp_batch"].Value = ds_move.Tables[0].Rows[i]["sp_batch"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_move.Tables[0].Rows[i]["sp_sku"].ToString().Trim();
                command.Parameters.Add("@sp_use_qty", SqlDbType.Decimal);
                command.Parameters["@sp_use_qty"].Precision = (byte)16;
                command.Parameters["@sp_use_qty"].Scale = (byte)4;
                command.Parameters["@sp_use_qty"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty"].ToString().Trim());
                command.Parameters.Add("@sp_use_qty_s", SqlDbType.Decimal);
                command.Parameters["@sp_use_qty_s"].Precision = (byte)16;
                command.Parameters["@sp_use_qty_s"].Scale = (byte)4;
                command.Parameters["@sp_use_qty_s"].Value = System.Convert.ToDecimal(ds_move.Tables[0].Rows[i]["sp_use_qty_s"].ToString().Trim());
                command.Parameters.Add("@sp_outloc", SqlDbType.Char, 20);
                command.Parameters["@sp_outloc"].Value = ds_move.Tables[0].Rows[i]["sp_outloc"].ToString().Trim();
                command.Parameters.Add("@sp_inloc", SqlDbType.Char, 20);
                command.Parameters["@sp_inloc"].Value = ds_move.Tables[0].Rows[i]["sp_inloc"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    #endregion

    //越库入库直接转快速出库
    [WebMethod]
    public string Sql_exec_proc_asntoso(string s_org, string s_consignor, string s_asnno, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_SQL_ASNTOSO";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asno", SqlDbType.Char, 20);
            command.Parameters["@sp_asno"].Value = s_asnno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //越库入库直接转快速出库
    [WebMethod]
    public string Sql_exec_proc_asntoso_new(string s_org, string s_consignor, string s_asnno, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_SQL_ASNTOSO_NEW";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asno", SqlDbType.Char, 20);
            command.Parameters["@sp_asno"].Value = s_asnno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //越库快速出库确认直接转对方入库单
    [WebMethod]
    public string Sql_exec_proc_transfer_asn(DataSet ds_tk, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction(); 
            /////质检确认的存储过程
            for (int i = 0; i < ds_tk.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_TRANSFER_ASN";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_tk.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_tk.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_tkno", SqlDbType.Char, 20);
                command.Parameters["@sp_tkno"].Value = ds_tk.Tables[0].Rows[i]["tk_no"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }  
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    #region 修改包装信息
    [WebMethod]
    public string Sql_exec_proc_checkpack(DataSet ds_change_pack)
    {
        string str_ls_middle;
        int i_count;
        SqlCommand command;
        str_ls_middle = "";
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            i_count = 0;
            for (int i = 0; i < ds_change_pack.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_CHECK_PACK";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_change_pack.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_change_pack.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_change_pack.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_new_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_new_pack"].Value = ds_change_pack.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim() + "/r/n";
                    i_count++;
                    if (i_count > 20) //说明超过20个物料有问题,退出
                    {
                        break;
                    }
                }
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    [WebMethod]
    public string Sql_exec_proc_changepack(DataSet ds_change_pack, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        str_ls_middle = "";
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_change_pack.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_CHANGE_PACK";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_change_pack.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_change_pack.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                command.Parameters["@sp_sku"].Value = ds_change_pack.Tables[0].Rows[i]["sku"].ToString().Trim();
                command.Parameters.Add("@sp_new_pack", SqlDbType.Char, 30);
                command.Parameters["@sp_new_pack"].Value = ds_change_pack.Tables[0].Rows[i]["pack_code"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }
    #endregion

    //宜昌结算单
    [WebMethod]
    public string Sql_exec_proc_asn_checkfee(string s_org, string s_csgor, string s_asn_no,DateTime dt_cur_time, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        str_ls_middle = "";
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandText = g_usespace + ".SP_SQL_ASN_CHECKFEE";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_csgor;
            command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
            command.Parameters["@sp_asn"].Value = s_asn_no;
            command.Parameters.Add("@sp_cur_day", SqlDbType.DateTime);
            command.Parameters["@sp_cur_day"].Value = dt_cur_time;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }  
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    [WebMethod]
    public string Sql_exec_proc_so_checkfee(DataSet ds_socheck, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        str_ls_middle = "";
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            for (int i = 0; i < ds_socheck.Tables[0].Rows.Count; i++)
            {
                if (i > 0) command.Parameters.Clear();
                command.CommandText = g_usespace + ".SP_SQL_SO_CHECKFEE";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = ds_socheck.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = ds_socheck.Tables[0].Rows[i]["consignor"].ToString().Trim();
                command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                command.Parameters["@sp_asn"].Value = ds_socheck.Tables[0].Rows[i]["asn_no"].ToString().Trim();
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_user;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    break;
                }
            }
            if (str_ls_middle.Trim() == "")
                SqldbCenter.Commit();
            else
                SqldbCenter.Rollback();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //////////////////////////////////// SQLCERVER数据库结束/////////////////////////////////////////////////////////
    ///////上海江森货主库存转移/////
    [WebMethod]
    public string Sql_exec_transfer_consignor(DataSet ds_trans,string str_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_trans.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_trans.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_SQL_TRANSFER_CONSIGNOR";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_trans.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_trans.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_tra", SqlDbType.Char, 20);
                    command.Parameters["@sp_tra"].Value = ds_trans.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                    command.Parameters["@sp_user"].Value = str_user;
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                        command.Parameters.Clear();
                        break;
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    ///////无锡江森使用的web服务////////
    //判断委外加工件入库时库存是否够用
    //command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
    //command.Parameters["@sp_qty"].Precision = (byte)16;
    //command.Parameters["@sp_qty"].Scale = (byte)4;
    //command.Parameters["@sp_qty"].Value = d_qty;
    [WebMethod]
    public string oracle_judge_receive_delegate(DataSet ds_receive_delegate)
    {
        string str_ls_middle;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            dbCenter.OpenConnection();
            dbCenter.BeginTransaction();
            if (ds_receive_delegate.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_receive_delegate.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_ORL_RECEIVE_SHORT";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("sp_org", OracleType.Char, 15);
                    command.Parameters["sp_org"].Value = ds_receive_delegate.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("sp_csgor", OracleType.Char, 15);
                    command.Parameters["sp_csgor"].Value = ds_receive_delegate.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("sp_sku", OracleType.Char, 30);
                    command.Parameters["sp_sku"].Value = ds_receive_delegate.Tables[0].Rows[i]["sku"].ToString().Trim();
                    command.Parameters.Add("sp_qtym", OracleType.Number, 16);
                    command.Parameters["sp_qtym"].Value = System.Convert.ToDecimal(ds_receive_delegate.Tables[0].Rows[i]["qty_m"].ToString().Trim());
                    command.Parameters.Add("sp_out", OracleType.VarChar, 100);
                    command.Parameters["sp_out"].Direction = ParameterDirection.Output;
                    dbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["sp_out"].Value.ToString().Trim() != "1")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["sp_out"].Value.ToString().Trim();
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "" || str_ls_middle.Trim().IndexOf("shortinventory") >= 0)
            {
                dbCenter.Commit();
            }
            else
            {
                dbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    [WebMethod]
    public string Sql_judge_receive_delegate(DataSet ds_receive_delegate)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            if (ds_receive_delegate.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds_receive_delegate.Tables[0].Rows.Count; i++)
                {
                    command.CommandText = g_usespace + ".SP_SQL_RECEIVE_SHORT";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                    command.Parameters["@sp_org"].Value = ds_receive_delegate.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                    command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                    command.Parameters["@sp_csgor"].Value = ds_receive_delegate.Tables[0].Rows[i]["consignor"].ToString().Trim();
                    command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
                    command.Parameters["@sp_sku"].Value = ds_receive_delegate.Tables[0].Rows[i]["sku"].ToString().Trim();
                    command.Parameters.Add("@sp_qtym", SqlDbType.Decimal);
                    command.Parameters["@sp_qtym"].Precision = (byte)16;
                    command.Parameters["@sp_qtym"].Scale = (byte)4;
                    command.Parameters["@sp_qtym"].Value = System.Convert.ToDecimal(ds_receive_delegate.Tables[0].Rows[i]["qty_m"].ToString().Trim());
                    command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                    command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                    SqldbCenter.ExecuteNonQuery(command);
                    if (command.Parameters["@sp_out"].Value.ToString().Trim() != "1")
                    {
                        str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                    }
                    command.Parameters.Clear();
                }
            }
            if (str_ls_middle.Trim() == "" || str_ls_middle.Trim().IndexOf("shortinventory") >= 0)
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //判断序列号是否重复
    [WebMethod]
    public Int32 Sql_judge_sequence(string s_org, string s_consignor, string s_sku, string s_sequence)
    {
        string s_str;
        Int32 r_int;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        r_int = 0;
        try
        {
            SqldbCenter.OpenConnection();
            s_str = "select count(*) from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and sku = '" + s_sku + "' and lot_attribute6 = '" + s_sequence + "'";
            command.CommandType = CommandType.Text;
            command.CommandText = s_str;
            r_int = SqldbCenter.ExecuteScalar(command);
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return r_int;
    }

    [WebMethod]
    public Int32 oracle_judge_sequence(string s_org, string s_consignor, string s_sku, string s_sequence)
    {
        string s_str;
        Int32 r_int;
        OracleCommand command;
        command = new OracleCommand();
        DatabaseController dbCenter = new DatabaseController();
        r_int = 0;
        try
        {
            dbCenter.OpenConnection();
            s_str = "select count(*) from " + g_usespace + ".asn_receive_detail where inv_org = '" + s_org + "' and consignor = '" + s_consignor + "' and sku = '" + s_sku + "' and lot_attribute6 = '" + s_sequence + "'";
            command.CommandType = CommandType.Text;
            command.CommandText = s_str;
            r_int = dbCenter.ExecuteScalar(command);
        }
        catch (System.Exception)
        {
            dbCenter.Rollback();
            throw;
        }
        finally
        {
            dbCenter.CloseConnection();
        }
        return r_int;
    }

    //拉动长江南路补货
    [WebMethod]
    public string Sql_exec_proc_pullsku(string s_org, string s_consignor, string s_so_no, string s_user)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PULL_WXJS");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_sono", SqlDbType.VarChar, 20);
            command.Parameters["@sp_sono"].Value = s_so_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
        }
        catch (System.Exception)
        { 
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }


    //上架确认存储过程
    [WebMethod]
    public string Sql_exec_proc_pacon_wxjs(string s_org, string s_consignor, string s_asn_no, int i_asnno, int i_recno, string s_pallet, string s_method, string s_user, string s_loc)
    {
        //string s_str;
        //Int32 i_count;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //////首先更新坐标点位置
            ////s_str = "select count(*) from " + g_usespace + ".inv_location where inv_org = '" + s_org + "' and location_code = '" + s_loc + "'";
            ////i_count = Sql_exec_selectint(s_str);
            ////if (i_count > 0) //说明有了,更新
            ////{
            ////    s_str = "update " + g_usespace + ".inv_location set coordinate = '" + s_method + "' where inv_org = '" + s_org + "' and location_code = '" + s_loc + "'";
            ////    command.CommandType = CommandType.Text;
            ////    command.CommandText = s_str;
            ////    SqldbCenter.ExecuteNonQuery(command);
            ////}
            ////else  //说明没有插入
            ////{
            ////    s_str = "insert into " + g_usespace + ".inv_location (inv_org, location_code,coordinate) values ('" + s_org + "','" + s_loc + "','" + s_method + "')";
            ////    command.CommandType = CommandType.Text;
            ////    command.CommandText = s_str;
            ////    SqldbCenter.ExecuteNonQuery(command);
            ////}
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_SQL_PA_CON_LIST";
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_asnno", SqlDbType.Char, 20);
            command.Parameters["@sp_asnno"].Value = s_asn_no;
            command.Parameters.Add("@sp_asnline", SqlDbType.Int);
            command.Parameters["@sp_asnline"].Value = i_asnno;
            command.Parameters.Add("@sp_recline", SqlDbType.Int);
            command.Parameters["@sp_recline"].Value = i_recno;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
            command.Parameters["@sp_method"].Value = "1";
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_output", SqlDbType.VarChar, 50);
            command.Parameters["@sp_output"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_output"].Value.ToString().Trim();
    }

    //拣货数量新增
    [WebMethod]
    public string Sql_exec_proc_pickadd_wxjs(string s_org, string s_consignor, string s_so_no, int i_line, string s_sku, string s_loc, string s_bat, string s_pallet, decimal d_qty, string s_user, string s_flag)
    {
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_PICK_ADD");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_line_no", SqlDbType.Int);
            command.Parameters["@sp_line_no"].Value = i_line;
            command.Parameters.Add("@sp_sku", SqlDbType.Char, 30);
            command.Parameters["@sp_sku"].Value = s_sku;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_loc;
            command.Parameters.Add("@sp_bat", SqlDbType.Char, 12);
            command.Parameters["@sp_bat"].Value = s_bat;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_qty", SqlDbType.Decimal);
            command.Parameters["@sp_qty"].Precision = (byte)16;
            command.Parameters["@sp_qty"].Scale = (byte)4;
            command.Parameters["@sp_qty"].Value = d_qty;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.Char, 1); 
            command.Parameters["@sp_flag"].Value = s_flag;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //移库数量新增
    [WebMethod]
    public string Sql_exec_proc_moveadd_wxjs(string s_org, string s_consignor, string s_move_no, int i_line, string s_outloc, string s_inloc, string s_pallet, string s_ipallet, string s_bat, decimal d_qty, decimal d_pallet_qty, string s_outware, string s_inware, string s_user, string s_flag)
    {
        //string s_str;
        //Int32 i_count;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            //首先更新坐标点位置
            ////s_str = "select count(*) from " + g_usespace + ".inv_location where inv_org = '" + s_org + "' and location_code = '" + s_inloc + "'";
            ////i_count = Sql_exec_selectint(s_str);
            ////if (i_count > 0) //说明有了,更新
            ////{
            ////    s_str = "update " + g_usespace + ".inv_location set coordinate = '" + s_flag + "',update_time = getdate() where inv_org = '" + s_org + "' and location_code = '" + s_inloc + "'";
            ////    command.CommandType = CommandType.Text;
            ////    command.CommandText = s_str;
            ////    SqldbCenter.ExecuteNonQuery(command);
            ////}
            ////else  //说明没有插入 
            ////{
            ////    s_str = "insert into " + g_usespace + ".inv_location (inv_org, location_code,coordinate) values ('" + s_org + "','" + s_inloc + "','" + s_flag + "')";
            ////    command.CommandType = CommandType.Text;
            ////    command.CommandText = s_str;
            ////    SqldbCenter.ExecuteNonQuery(command);
            ////}
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = g_usespace + ".SP_SQL_MOVE_ADD";
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_moveno", SqlDbType.Char, 20);
            command.Parameters["@sp_moveno"].Value = s_move_no;
            command.Parameters.Add("@sp_lineon", SqlDbType.Int);
            command.Parameters["@sp_lineon"].Value = i_line;
            command.Parameters.Add("@sp_moveout", SqlDbType.Char, 20);
            command.Parameters["@sp_moveout"].Value = s_outloc;
            command.Parameters.Add("@sp_movein", SqlDbType.Char, 20);
            command.Parameters["@sp_movein"].Value = s_inloc;
            command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
            command.Parameters["@sp_pallet"].Value = s_pallet;
            command.Parameters.Add("@sp_inpallet", SqlDbType.Char, 15);
            command.Parameters["@sp_inpallet"].Value = s_ipallet;
            command.Parameters.Add("@sp_batch", SqlDbType.Char, 12);
            command.Parameters["@sp_batch"].Value = s_bat;
            command.Parameters.Add("@sp_use_qty", SqlDbType.Decimal);
            command.Parameters["@sp_use_qty"].Precision = (byte)16;
            command.Parameters["@sp_use_qty"].Scale = (byte)4;
            command.Parameters["@sp_use_qty"].Value = d_qty;
            command.Parameters.Add("@sp_pallet_qtym", SqlDbType.Decimal);
            command.Parameters["@sp_pallet_qtym"].Precision = (byte)16;
            command.Parameters["@sp_pallet_qtym"].Scale = (byte)4;
            command.Parameters["@sp_pallet_qtym"].Value = d_pallet_qty;
            command.Parameters.Add("@sp_outloc", SqlDbType.Char, 5);
            command.Parameters["@sp_outloc"].Value = s_outware;
            command.Parameters.Add("@sp_inloc", SqlDbType.Char, 5);
            command.Parameters["@sp_inloc"].Value = s_inware;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_flag", SqlDbType.Char, 1);
            command.Parameters["@sp_flag"].Value = "1";
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "0")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //上海江森转出库
    [WebMethod]
    public string Sql_pick_transfer_js(string s_org, string s_consignor, string s_so_no, string s_taxno, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = g_usespace + ".SP_SQL_PICK_TRANSFER_JS";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);   
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_lotstr", SqlDbType.Char, 300);
            command.Parameters["@sp_lotstr"].Value = s_taxno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //上海江森BOM入库
    [WebMethod]
    public string Sql_bom_skureceive_js(string s_org, string s_consignor, string s_in_no, string s_locno, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = g_usespace + ".SP_SQL_BOMSKU_RECEIVE";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_inno", SqlDbType.Char, 20);
            command.Parameters["@sp_inno"].Value = s_in_no;
            command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
            command.Parameters["@sp_loc"].Value = s_locno;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }


    //上海江森BOM入库分配取消
    [WebMethod]
    public string Sql_bom_skucancel_js(string s_org, string s_consignor, string s_in_no, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            //首先更新数据
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandText = g_usespace + ".SP_SQL_BOMSKU_CANCEL";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_inno", SqlDbType.Char, 20);
            command.Parameters["@sp_inno"].Value = s_in_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
            }
            if (str_ls_middle.Trim() == "")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle.Trim();
    }

    //无锡江森入库单接口
    [WebMethod]
    public jm_exception JM_GET_ASN(jm_asn_order[] ds_asn, string s_user)
    {
        //返回""表示没有单据存在， 返回"-1"失败 ，返回"0"成功
        string str_flag, str_sql;
        string str_return, str_no;
        Int32 i_count, i_cur_row, i_rec_no;
        Int32 tmp_page;
        DataSet ds_no;
        jm_exception jmexcep = new jm_exception();
        str_flag = "";
        ds_no = new DataSet();
        if (ds_asn.Length > 0) //需要有订单
        {
            SqlCommand command;
            command = new SqlCommand();
            SqlDatabaseController SqldbCenter = new SqlDatabaseController();
            SqlCommand command1;
            command1 = new SqlCommand();
            SqlDatabaseController SqldbCenter1 = new SqlDatabaseController();
            try
            {
                SqldbCenter.OpenConnection();
                SqldbCenter1.OpenConnection();
                SqldbCenter.BeginTransaction();
                for (int i = 0; i < ds_asn.Length; i++)  //一个table就是一个订单
                {
                    if (ds_asn[i].Order_Detail.Length > 0) //说明有订单
                    {
                        str_sql = "select count(*) from " + g_usespace + ".mst_customer where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Supply.ToString().Trim() + "' and supply_flag = '1'";
                        command1.CommandType = CommandType.Text;
                        command1.CommandText = str_sql;
                        i_count = SqldbCenter1.ExecuteScalar(command1);
                        if (i_count > 0)
                        {
                            //判断订单号是否为空
                            if (ds_asn[i].Asn_No.ToString().Trim() == "") //自动产生WMS的订单号
                            {
                                tmp_page = Sql_get_accountno(ds_asn[i].Inv_Org.ToString().Trim(), "ASN_NO");
                                str_no = tmp_page.ToString().PadLeft(4, '0');
                                str_return = tmp_page.ToString().PadLeft(8, '0');
                                str_sql = "select id_data,memo,substring(convert(char(10),getdate(),112),3,6) as s_date from " + g_usespace + ".Sys_Parameter where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and id = 8107";
                                ds_no = null;
                                ds_no = Sql_exec_selectsql(str_sql);
                                if (ds_no.Tables[0].Rows.Count > 0)
                                {
                                    if (ds_no.Tables[0].Rows[0]["id_data"].ToString().Trim() == "1") //说明用特定的格式字母+yymmddxxxx
                                    {
                                        ds_asn[i].Asn_No = ds_no.Tables[0].Rows[0]["memo"].ToString().Trim() + ds_no.Tables[0].Rows[0]["s_date"].ToString().Trim() + str_no;
                                    }
                                    else
                                    {
                                        ds_asn[i].Asn_No = "AN" + str_return;
                                    }
                                }
                                else
                                {
                                    ds_asn[i].Asn_No = "AN" + str_return;
                                }
                            }
                            str_sql = "insert into " + g_usespace + ".asn_order_header (inv_org,	consignor,	asn_no,		customer_order_no," +
                                                                    "eas_order,	contract_no,	order_day,	asn_type," +
                                                                    "supply,		supply_country,	supply_address,	supply_city," +
                                                                    "supply_province,	supply_postalcode,	supply_phone,	carrier," +
                                                                    "carrier_address,	carrier_postalcode,	carrier_phone,	ship_no," +
                                                                    "fly_no,		vehicle_no,	load_place,	discharge_place," +
                                                                    "deliver_place,	in_tax,		out_tax,	arrive_plan_day," +
                                                                    "arrive_deadline,	arrive_day,	asn_status,	arrive_status," +
                                                                    "colse_day,	colser,		book_status,	book_time," +
                                                                    "door,		booker,		standby_1,	standby_2," +
                                                                    "standby_3,	standby_4,	standby_5,	buyer," +
                                                                    "from_inv_org,	so_no,		memo,		main_dist," +
                                                                    "made_time,	maker)" +
                                                            " select '" + ds_asn[i].Inv_Org.ToString().Trim() + "','" + ds_asn[i].Consignor.ToString().Trim() + "','" + ds_asn[i].Asn_No.ToString().Trim() + "','" + ds_asn[i].Customer_Order_No.ToString().Trim() + "'," +
                                                                     "'','','" + ds_asn[i].Order_Day.ToString().Trim() + "','" + ds_asn[i].Asn_Type.ToString().Trim() + "'," +
                                                                    "consignor,		country,	business_address,	city," +
                                                                    "province,	postalcode,	telephone,	'" + ds_asn[i].Contact.ToString().Trim() + "'," +
                                                                    "'" + ds_asn[i].Location.ToString().Trim() + "','','" + ds_asn[i].Telephone.ToString().Trim() + "',''," +
                                                                    "'','" + ds_asn[i].Delivery_No.ToString().Trim() + "','',''," +
                                                                    "''," + ds_asn[i].In_Tax.ToString().Trim() + "," + ds_asn[i].Out_Tax.ToString().Trim() + ",'" + ds_asn[i].Arrive_Plan_Day.ToString().Trim() + "'," +
                                                                    "'','','0','0'," +
                                                                    "'','','1',getdate()," +
                                                                    "'','','','0'," +
                                                                    "'',1,0,'" + ds_asn[i].Buyer.ToString().Trim() + "'," +
                                                                    "'','','','A',getdate(),'" + s_user + "'" +
                                                            " from " + g_usespace + ".mst_customer where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Supply.ToString().Trim() + "' and supply_flag = '1'";
                        }
                        else
                        {
                            str_flag = "-1";
                            jmexcep.Str_Error_Message = "供应商" + ds_asn[i].Supply.ToString().Trim() + "不存在!";
                            break;
                        }
                        command.CommandType = CommandType.Text;
                        command.CommandText = str_sql;
                        SqldbCenter.ExecuteNonQuery(command);
                        i_cur_row = 0;
                        //循环插入明细信息
                        for (int j = 0; j < ds_asn[i].Order_Detail.Length; j++)
                        {
                            str_sql = "select count(*) from " + g_usespace + ".mst_sku where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' and sku ='" + ds_asn[i].Order_Detail[j].Sku.ToString().Trim() + "'";
                            command1.CommandType = CommandType.Text;
                            command1.CommandText = str_sql;
                            i_count = SqldbCenter1.ExecuteScalar(command1);
                            if (i_count > 0)
                            {
                                if (ds_asn[i].Order_Detail[j].Lot_Attribute3.ToString().Trim() == "")
                                {
                                    ds_asn[i].Order_Detail[j].Lot_Attribute3 = "非保税";
                                }
                                i_cur_row = i_cur_row + 1;
                                str_sql = "insert into " + g_usespace + ".asn_order_detail (inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                    "eas_order,	order_line_no,	sku,		pack_code," +
                                                                                    "order_qty_m,	order_qty_s,	present_qty_m,	present_qty_s," +
                                                                                    "order_price,	order_unit,	cubage,		gross_weight," +
                                                                                    "net_weight,	shelflife_day,	receive_qty_m,	receive_qty_s," +
                                                                                    "receive_present_qty_m,	receive_present_qty_s,	main_sub_flag,	convert_modulus," +
                                                                                    "receive_day,	receive_status,	lot_attribute1,	lot_attribute2," +
                                                                                    "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                                    "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                                    "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                    "lot_attribute15,	standby_1,	standby_2,	standby_3," +
                                                                                    "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                    "tax_dist,	doc_link,	memo,		main_dist," +
                                                                                    "made_time,	maker)" +
                                                              " select  '" + ds_asn[i].Inv_Org.ToString().Trim() + "','" + ds_asn[i].Consignor.ToString().Trim() + "','" + ds_asn[i].Asn_No.ToString().Trim() + "'," + i_cur_row.ToString().Trim() + "," +
                                                                        "'',0,'" + ds_asn[i].Order_Detail[j].Sku.ToString().Trim() + "',pack_code," +
                                                                        ds_asn[i].Order_Detail[j].Order_Qty_M.ToString().Trim() + "," + ds_asn[i].Order_Detail[j].Order_Qty_M.ToString().Trim() + "," + ds_asn[i].Order_Detail[j].Present_Qty_M.ToString().Trim() + "," + ds_asn[i].Order_Detail[j].Present_Qty_M.ToString().Trim() + "," +
                                                                        ds_asn[i].Order_Detail[j].Order_Price.ToString().Trim() + ",'" + ds_asn[i].Order_Detail[j].Order_Unit.ToString().Trim() + "',Round(cubage * " + ds_asn[i].Order_Detail[j].Order_Qty_M.ToString().Trim() + ",4),Round(gross_weight * " + ds_asn[i].Order_Detail[j].Order_Qty_M.ToString().Trim() + ",4)," +
                                                                        "Round(net_weight * " + ds_asn[i].Order_Detail[j].Order_Qty_M.ToString().Trim() + ",4),	shelflife_day,	0,	0," +
                                                                        "0,	0,	main_sub_flag,	convert_modulus," +
                                                                        "'',	'0',	'" + ds_asn[i].Order_Detail[j].Lot_Attribute1.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute2.ToString().Trim() + "','" +
                                                                        ds_asn[i].Order_Detail[j].Lot_Attribute3.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute4.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute5.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute6.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute7.ToString().Trim() + "','" +
                                                                        ds_asn[i].Order_Detail[j].Lot_Attribute8.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute9.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute10.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute11.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute12.ToString().Trim() + "','" +
                                                                        ds_asn[i].Order_Detail[j].Lot_Attribute13.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Lot_Attribute14.ToString().Trim() + "','" +
                                                                        ds_asn[i].Order_Detail[j].Lot_Attribute15.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Qa_Control.ToString().Trim() + "','',''," +
                                                                        "'','" + ds_asn[i].Order_Detail[j].Is_Urgent.ToString().Trim() + "',0,0,'" +
                                                                        ds_asn[i].Order_Detail[j].Lot_Attribute3.ToString().Trim() + "','" + ds_asn[i].Order_Detail[j].Doc_Link.ToString().Trim() + "','','A',getdate(),'" + s_user + "'" +
                                                              " from " + g_usespace + ".mst_sku where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' and sku ='" + ds_asn[i].Order_Detail[j].Sku.ToString().Trim() + "'";
                                command.CommandType = CommandType.Text;
                                command.CommandText = str_sql;
                                SqldbCenter.ExecuteNonQuery(command);
                                //判断标志是否直接进行收货确认
                                if (ds_asn[i].Interface_Type.ToString().Trim() == "1")  //需要直接入库,目前只能做到非托盘管理的直接入库操作
                                {
                                    //首次判断库位是否合法
                                    str_sql = "select count(*) from " + g_usespace + ".mst_location where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and location_code = '" + ds_asn[i].Order_Detail[j].Fact_Location.ToString().Trim() + "' and main_dist <> 'D'";
                                    command1.CommandType = CommandType.Text;
                                    command1.CommandText = str_sql;
                                    i_count = SqldbCenter1.ExecuteScalar(command1);
                                    if (i_count > 0)  //合法，进行入库确认
                                    {
                                        //插入收货确认表
                                        //得到最大行号
                                        str_sql = "select isnull(max(receive_line_no),0) from " + g_usespace + ".asn_receive_detail where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' " +
                                                "and asn_no ='" + ds_asn[i].Asn_No.ToString().Trim() + "' and asn_line_no =" + i_cur_row.ToString().Trim();
                                        command1.CommandType = CommandType.Text;
                                        command1.CommandText = str_sql;
                                        i_rec_no = SqldbCenter1.ExecuteScalar(command1);
                                        i_rec_no = i_rec_no + 1;
                                        //插入收货数据
                                        str_sql = "insert into " + g_usespace + ".asn_receive_detail(inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                                "receive_line_no,	sku,		pack_code,	order_price," +
                                                                                                "order_unit,	cubage,		gross_weight,	net_weight," +
                                                                                                "shelflife_day,	receive_qty_m,	receive_qty_s,	receive_present_qty_m," +
                                                                                                "receive_present_qty_s,	main_sub_flag,	convert_modulus,	receive_day," +
                                                                                                "fact_status,	lot_attribute1,	lot_attribute2,	lot_attribute3," +
                                                                                                "lot_attribute4,	lot_attribute5,	lot_attribute6,	lot_attribute7," +
                                                                                                "lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11," +
                                                                                                "lot_attribute12,	lot_attribute13,	lot_attribute14,	lot_attribute15," +
                                                                                                "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                                                "standby_5,	standby_6,	standby_7,	memo," +
                                                                                                "main_dist,	made_time,	maker) " +
                                                                                        "select inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                                i_rec_no.ToString().Trim() + ",  sku,		pack_code,order_price," +
                                                                                                "order_unit,	cubage,		     gross_weight,net_weight," +
                                                                                                "shelflife_day,	order_qty_m,	order_qty_s,present_qty_m," +
                                                                                                "present_qty_s, main_sub_flag,	convert_modulus,convert(char(10),getdate(),102)," +
                                                                                                "'1',	lot_attribute1,	convert(char(10),getdate(),102),lot_attribute3," +
                                                                                                "asn_no,	lot_attribute5,	lot_attribute6,lot_attribute7," +
                                                                                                "lot_attribute8,	lot_attribute9,	lot_attribute10,lot_attribute11," +
                                                                                                "lot_attribute12,	lot_attribute13,	lot_attribute14,lot_attribute15," +
                                                                                                "standby_1,	standby_2,	standby_3,standby_4," +
                                                                                                "'1',	standby_6,	standby_7,memo," +
                                                                                                "main_dist,getdate(),	maker " +
                                                                                       "from " + g_usespace + ".asn_order_detail " +
                                                                                       "where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' " +
                                                                                         "and asn_no ='" + ds_asn[i].Asn_No.ToString().Trim() + "' and asn_line_no =" + i_cur_row.ToString().Trim();
                                        command.CommandType = CommandType.Text;
                                        command.CommandText = str_sql;
                                        SqldbCenter.ExecuteNonQuery(command);
                                        //修改订单明细的状态
                                        str_sql = "update " + g_usespace + ".asn_order_detail set receive_qty_m = order_qty_m," +
                                                                                           "receive_qty_s = order_qty_s," +
                                                                                           "receive_present_qty_m = present_qty_m," +
                                                                                           "receive_present_qty_s = present_qty_s," +
                                                                                           "receive_day = convert(char(10),getdate(),102)," +
                                                                                           "receive_status = '2'," +
                                                                                           "main_dist = 'C',update_time = getdate(),updater='" + s_user + "' where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' " +
                                                                                         "and asn_no ='" + ds_asn[i].Asn_No.ToString().Trim() + "' and asn_line_no =" + i_cur_row.ToString().Trim();
                                        command.CommandType = CommandType.Text;
                                        command.CommandText = str_sql;
                                        SqldbCenter.ExecuteNonQuery(command);
                                        //插入拆板记录
                                        str_sql = "insert into " + g_usespace + ".asn_pallet_split( inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                                    "receive_line_no,	pallet_no,	sku,		pack_code," +
                                                                                                    "shelflife_day,	pallet_qty_m,	pallet_qty_s,	main_sub_flag," +
                                                                                                    "convert_modulus,	order_price,	order_unit,	cubage," +
                                                                                                    "gross_weight,	net_weight,	spliter,	split_status," +
                                                                                                    "split_date,	lot_attribute1,	lot_attribute2,	lot_attribute3," +
                                                                                                    "lot_attribute4,	lot_attribute5,	lot_attribute6,	lot_attribute7," +
                                                                                                    "lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11," +
                                                                                                    "lot_attribute12,	lot_attribute13,	lot_attribute14,	lot_attribute15," +
                                                                                                    "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                                                    "standby_5,	standby_6,	standby_7,	memo," +
                                                                                                    "main_dist,	made_time,	maker) " +
                                                                                 " select   inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                           "receive_line_no,	'000000000000000',  sku,		pack_code," +
                                                                                           "shelflife_day,	receive_qty_m + receive_present_qty_m,	receive_qty_s + receive_present_qty_s,main_sub_flag," +
                                                                                           "convert_modulus,order_price,order_unit,	cubage," +
                                                                                           "gross_weight,	net_weight,'" + s_user + "','1'," +
                                                                                           "convert(char(10),getdate(),102),lot_attribute1,	lot_attribute2,	lot_attribute3," +
                                                                                           "lot_attribute4,	lot_attribute5,	lot_attribute6,	lot_attribute7," +
                                                                                           "lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11," +
                                                                                           "lot_attribute12,	lot_attribute13,	lot_attribute14,	lot_attribute15," +
                                                                                           "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                                           "standby_5,	standby_6,	standby_7,	memo," +
                                                                                           "main_dist,	made_time,	maker" +
                                                                                  " from " + g_usespace + ".asn_receive_detail where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' " +
                                                                                         "and asn_no ='" + ds_asn[i].Asn_No.ToString().Trim() + "' and asn_line_no =" + i_cur_row.ToString().Trim() + " and receive_line_no = " + i_rec_no.ToString().Trim();
                                        command.CommandType = CommandType.Text;
                                        command.CommandText = str_sql;
                                        SqldbCenter.ExecuteNonQuery(command);
                                        ////插入上架表
                                        str_sql = "insert into " + g_usespace + ".asn_putaway(inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                            "receive_line_no,	pallet_no,	sku,		pack_code," +
                                                                                            "suggest_location,	shelflife_day,	putaway_qty_m,	putaway_qty_s," +
                                                                                            "main_sub_flag,	convert_modulus,	order_price,	order_unit," +
                                                                                            "cubage,		gross_weight,	net_weight,	putaway_status," +
                                                                                            "fact_location,	putawayer,	putaway_flag,	putaway_date," +
                                                                                            "print_flag,	printer,	label_flag," +
                                                                                            "labeler,	lot_attribute1,	lot_attribute2," +
                                                                                            "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                                            "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                                            "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                            "lot_attribute15,	standby_1,	standby_2,	standby_3," +
                                                                                            "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                            "memo,		main_dist,	made_time,	maker)" +
                                                                                " select inv_org,	consignor,	asn_no,		asn_line_no," +
                                                                                        "receive_line_no,	pallet_no,	sku,		pack_code,'" +
                                                                                        ds_asn[i].Order_Detail[j].Fact_Location.ToString().Trim() + "',shelflife_day,	pallet_qty_m,	pallet_qty_s," +
                                                                                        "main_sub_flag,convert_modulus,	order_price,	order_unit," +
                                                                                        "cubage,gross_weight,	net_weight,	'0'," +
                                                                                        "'','','',''," +
                                                                                        "'','','',''," +
                                                                                        "lot_attribute1,	lot_attribute2,	lot_attribute3," +
                                                                                        "lot_attribute4,	lot_attribute5,	lot_attribute6,	lot_attribute7," +
                                                                                        "lot_attribute8,	lot_attribute9,	lot_attribute10,	lot_attribute11," +
                                                                                        "lot_attribute12,	lot_attribute13,	lot_attribute14,	lot_attribute15," +
                                                                                        "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                                        "standby_5,	standby_6,	standby_7,	memo," +
                                                                                        "main_dist,	getdate(),	maker" +
                                                                             " from " + g_usespace + ".asn_pallet_split where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' " +
                                                                       "and asn_no ='" + ds_asn[i].Asn_No.ToString().Trim() + "' and asn_line_no =" + i_cur_row.ToString().Trim() + " and receive_line_no = " + i_rec_no.ToString().Trim() + " and pallet_no = '000000000000000'";
                                        command.CommandType = CommandType.Text;
                                        command.CommandText = str_sql;
                                        SqldbCenter.ExecuteNonQuery(command);
                                        //调用上架确认的存储过程
                                        command.CommandType = CommandType.StoredProcedure;
                                        command.CommandText = g_usespace + ".SP_SQL_PA_CONFIRM";
                                        command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                                        command.Parameters["@sp_org"].Value = ds_asn[i].Inv_Org.ToString().Trim();
                                        command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                                        command.Parameters["@sp_csgor"].Value = ds_asn[i].Consignor.ToString().Trim();
                                        command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                                        command.Parameters["@sp_asn"].Value = ds_asn[i].Asn_No.ToString().Trim();
                                        command.Parameters.Add("@sp_lineno", SqlDbType.Int);
                                        command.Parameters["@sp_lineno"].Value = i_cur_row;
                                        command.Parameters.Add("@sp_recno", SqlDbType.Int);
                                        command.Parameters["@sp_recno"].Value = i_rec_no;
                                        command.Parameters.Add("@sp_pallet", SqlDbType.Char, 15);
                                        command.Parameters["@sp_pallet"].Value = "000000000000000";
                                        command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                                        command.Parameters["@sp_user"].Value = s_user;
                                        command.Parameters.Add("@sp_method", SqlDbType.Char, 1);
                                        command.Parameters["@sp_method"].Value = "0";
                                        command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
                                        command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                                        SqldbCenter.ExecuteNonQuery(command);
                                        if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                                        {
                                            str_flag = "-1";
                                            jmexcep.Str_Error_Message = command.Parameters["@sp_out"].Value.ToString().Trim();
                                            command.Parameters.Clear();
                                            break;  
                                        }
                                        command.Parameters.Clear();
                                        command.CommandType = CommandType.Text;
                                        //修改表头的状态是收获确认
                                        str_sql = "update " + g_usespace + ".asn_order_header set arrive_day = convert(char(10),getdate(),102),arrive_status = '2',main_dist = 'C',update_time=getdate(),updater='" + s_user +
                                                  "' where inv_org = '" + ds_asn[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_asn[i].Consignor.ToString().Trim() + "' and asn_no ='" + ds_asn[i].Asn_No.ToString().Trim() + "'";
                                        command.CommandText = str_sql;
                                        SqldbCenter.ExecuteNonQuery(command);
                                    }
                                    else  //不合法  
                                    {
                                        str_flag = "-1";
                                        jmexcep.Str_Error_Message = "库位" + ds_asn[i].Order_Detail[j].Fact_Location.ToString().Trim() + "不存在!";
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                str_flag = "-1";
                                jmexcep.Str_Error_Message = "物料" + ds_asn[i].Order_Detail[j].Sku.ToString().Trim() + "不存在!";
                                break;
                            }
                            
                        }
                        if (str_flag == "-1")
                        {
                            break;
                        }
                    }
                }  
                if (str_flag != "-1")
                {
                    SqldbCenter.Commit();
                    str_flag = "0";
                }
                else
                {
                    SqldbCenter.Rollback();
                }
            }
            catch (System.Exception ee)
            {
                str_flag = "-1";
                jmexcep.Str_Error_Message = ee.Message.ToString().Trim();
                jmexcep.Str_Memo = ee.ToString().Trim();
                SqldbCenter.Rollback();
                //              nvl throw;
            }
            finally
            {
                SqldbCenter.CloseConnection();
                SqldbCenter1.CloseConnection();
            }
        }
        jmexcep.Str_Code = str_flag;
        return jmexcep;
    }

    //无锡江森出库单接口
    [WebMethod]
    public jm_exception JM_GET_SO(jm_so_order[] ds_so, string s_user)
    {
        string str_flag, str_sql;
        string str_return, str_no;
        Int32 i_count, i_cur_row;
        Int32 tmp_page;
        DataSet ds_no;
        jm_exception jmexcep = new jm_exception();
        str_flag = "";
        ds_no = new DataSet();

        if (ds_so.Length > 0) //说明有订单
        {
            SqlCommand command;
            command = new SqlCommand();
            SqlDatabaseController SqldbCenter = new SqlDatabaseController();
            SqlCommand command1;
            command1 = new SqlCommand();
            SqlDatabaseController SqldbCenter1 = new SqlDatabaseController();

            try
            {
                SqldbCenter.OpenConnection();
                SqldbCenter1.OpenConnection();
                SqldbCenter.BeginTransaction();
                for (int i = 0; i < ds_so.Length; i++)  //一个table就是一个订单
                {
                    if (ds_so[i].So_Order_Detail.Length > 0) //说明有订单
                    {
                        //判断订单号是否为空
                        if (ds_so[i].So_No.ToString().Trim() == "") //自动产生WMS的订单号
                        {
                            tmp_page = Sql_get_accountno(ds_so[i].Inv_Org.ToString().Trim(), "SO_NO");
                            str_no = tmp_page.ToString().PadLeft(4, '0');
                            str_return = tmp_page.ToString().PadLeft(8, '0');
                            str_sql = "select id_data,memo,substring(convert(char(10),getdate(),112),3,6) as s_date from " + g_usespace + ".Sys_Parameter where inv_org = '" + ds_so[i].Inv_Org.ToString().Trim() + "' and id = 8108";
                            ds_no = null;
                            ds_no = Sql_exec_selectsql(str_sql);
                            if (ds_no.Tables[0].Rows.Count > 0)
                            {
                                if (ds_no.Tables[0].Rows[0]["id_data"].ToString().Trim() == "1") //说明用特定的格式字母+yymmddxxxx
                                {
                                    ds_so[i].So_No = ds_no.Tables[0].Rows[0]["memo"].ToString().Trim() + ds_no.Tables[0].Rows[0]["s_date"].ToString().Trim() + str_no;
                                }
                                else
                                {
                                    ds_so[i].So_No = "SO" + str_return;
                                }
                            }
                            else
                            {
                                ds_so[i].So_No = "SO" + str_return;
                            }
                        }
                        str_sql = "insert into " + g_usespace + ".so_ship_header (inv_org,	consignor,	so_no,		eas_no," +
                                                                                "customer_sale_no,	customer_code,	customer_name,	address," +
                                                                                "receiver,	telephone,	carrier_name,	carrier," +
                                                                                "carrier_address,	carrier_postalcode,	carrier_phone,	ship_no," +
                                                                                "fly_no,		vehicle_no,	receive_day,	so_day," +
                                                                                "rush_flag,	cross_flag,	so_type,	original_order_no," +
                                                                                "so_prior,	print_day,	printer,	confirm_day," +
                                                                                "confirmer,	ship_day,	shipper,	wave_flag," +
                                                                                "so_flag,	so_status,	so_assign,	colse_day," +
                                                                                "colser,		door,		to_inv_org,	buyer," +
                                                                                "project_name,	preparer," +
                                                                                "telephone2,	standby_1,	standby_2,	standby_3," +
                                                                                "standby_4,	standby_5,	standby_6,	standby_7," +
                                                                                "standby_8,	standby_9,	standby_10,	standby_11," +
                                                                                "standby_12,	standby_13,	standby_14,	mechine_no," +
                                                                                "work_position,	line_type,	sequence_no,	mechine_type," +
                                                                                "auditer,		applier,	ld_dist," +
                                                                                "memo,		memo2,		main_dist,	made_time,  maker)" +
                                                                      " values ('" + ds_so[i].Inv_Org.ToString().Trim() + "','" + ds_so[i].Consignor.ToString().Trim() + "','" + ds_so[i].So_No.ToString().Trim() + "','','" +
                                                                             ds_so[i].Customer_Sale_No.ToString().Trim() + "','" + ds_so[i].Customer_Code.ToString().Trim() + "','" + ds_so[i].Customer_Name.ToString().Trim() + "','" + ds_so[i].Location.ToString().Trim() + "'," +
                                                                             "'','','','" + ds_so[i].Contact.ToString().Trim() + "'," +
                                                                             "'','','" + ds_so[i].Telephone.ToString().Trim() + "',''," +
                                                                             "'','','','" + ds_so[i].So_Day.ToString().Trim() + "'," +
                                                                             "'0','0','" + ds_so[i].So_Type.ToString().Trim() + "','" + ds_so[i].Original_Order_No.ToString().Trim() + "'," +
                                                                             "0,'','',''," +
                                                                             "'','','','0'," +
                                                                             "'0','0','0',''," +
                                                                             "'','','',''," +
                                                                             "'',''," +
                                                                             "'','','',''," +
                                                                             "1,0,'',''," +
                                                                             "'',0,0,''," +
                                                                             "'','','',''," + 
                                                                             "'','','',''," +
                                                                             "'','','0'," +
                                                                             "'','','A',getdate(),'" + s_user + "')";
                        command.CommandType = CommandType.Text;
                        command.CommandText = str_sql;
                        SqldbCenter.ExecuteNonQuery(command);
                        i_cur_row = 0;
                        //循环插入明细信息
                        for (int j = 0; j < ds_so[i].So_Order_Detail.Length; j++)
                        {
                            str_sql = "select count(*) from " + g_usespace + ".mst_sku where inv_org = '" + ds_so[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_so[i].Consignor.ToString().Trim() + "' and sku ='" + ds_so[i].So_Order_Detail[j].Sku.ToString().Trim() + "'";
                            command1.CommandType = CommandType.Text;
                            command1.CommandText = str_sql;
                            i_count = SqldbCenter1.ExecuteScalar(command1);
                            if (i_count > 0)
                            {
                                if (ds_so[i].So_Order_Detail[j].Lot_Attribute3.ToString().Trim() == "")
                                {
                                    ds_so[i].So_Order_Detail[j].Lot_Attribute3 = "非保税";
                                }
                                i_cur_row = i_cur_row + 1;
                                str_sql = "insert into " + g_usespace + ".so_ship_detail (inv_org,	consignor,	so_no,		so_line_no," +
                                                                                        "sku,		pack_code,	plan_so_qty_m,	plan_so_qty_s," +
                                                                                        "allocate_qty_m,	allocate_qty_s,	pick_qty_m,	pick_qty_s," +
                                                                                        "ship_qty_m,	ship_qty_s,	order_price,	order_unit," +
                                                                                        "plan_cubage,	plan_gross_weight,	plan_net_weight,	allocate_cubage," +
                                                                                        "allocate_gross_weight,	allocate_net_weight,	pick_cubage,	pick_gross_weight," +
                                                                                        "pick_net_weight,	ship_cubage,	ship_gross_weight,	ship_net_weight," +
                                                                                        "main_sub_flag,	convert_modulus,	lot_attribute1,	lot_attribute2," +
                                                                                        "lot_attribute3,	lot_attribute4,	lot_attribute5,	lot_attribute6," +
                                                                                        "lot_attribute7,	lot_attribute8,	lot_attribute9,	lot_attribute10," +
                                                                                        "lot_attribute11,	lot_attribute12,	lot_attribute13,	lot_attribute14," +
                                                                                        "lot_attribute15,	eas_sale_no,	sale_line_no,	need_time," +
                                                                                        "standby_1,	standby_2,	standby_3,	standby_4," +
                                                                                        "standby_5,	standby_6,	standby_7,	so_status," +
                                                                                        "memo,		main_dist,	made_time,	maker)" +
                                                              " select  '" + ds_so[i].Inv_Org.ToString().Trim() + "','" + ds_so[i].Consignor.ToString().Trim() + "','" + ds_so[i].So_No.ToString().Trim() + "'," + i_cur_row.ToString().Trim() + ",'" +
                                                                        ds_so[i].So_Order_Detail[j].Sku.ToString().Trim() + "',pack_code," + ds_so[i].So_Order_Detail[j].Plan_So_Qty_M.ToString().Trim() + "," + ds_so[i].So_Order_Detail[j].Plan_So_Qty_M.ToString().Trim() + "," +
                                                                        "0,0,0,0," +
                                                                        "0,0," + ds_so[i].So_Order_Detail[j].Order_Price.ToString().Trim() + ",'" + ds_so[i].So_Order_Detail[j].Order_Unit.ToString().Trim() + "'," +
                                                                        "Round(cubage * " + ds_so[i].So_Order_Detail[j].Plan_So_Qty_M.ToString().Trim() + ",4),Round(gross_weight * " + ds_so[i].So_Order_Detail[j].Plan_So_Qty_M.ToString().Trim() + ",4),Round(net_weight * " + ds_so[i].So_Order_Detail[j].Plan_So_Qty_M.ToString().Trim() + ",4),0," +
                                                                        "0,0,0,0," +
                                                                        "0,0,0,0," +
                                                                        "main_sub_flag,	convert_modulus,'" + ds_so[i].So_Order_Detail[j].Lot_Attribute1.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute2.ToString().Trim() + "','" +
                                                                        ds_so[i].So_Order_Detail[j].Lot_Attribute3.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute4.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute5.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute6.ToString().Trim() + "','" +
                                                                        ds_so[i].So_Order_Detail[j].Lot_Attribute7.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute8.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute9.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute10.ToString().Trim() + "','" +
                                                                        ds_so[i].So_Order_Detail[j].Lot_Attribute11.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute12.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute13.ToString().Trim() + "','" + ds_so[i].So_Order_Detail[j].Lot_Attribute14.ToString().Trim() + "','" +
                                                                        ds_so[i].So_Order_Detail[j].Lot_Attribute15.ToString().Trim() + "','',0,convert(datetime,'" + ds_so[i].So_Order_Detail[j].Req_Time.ToLongTimeString().Trim() + "')," +
                                                                        "'','','','','" +
                                                                        ds_so[i].So_Order_Detail[j].Is_Urgent.ToString().Trim() + "',0,0,'0'," +
                                                                        "'','A',getdate(),'" + s_user + "'" +
                                                              " from " + g_usespace + ".mst_sku where inv_org = '" + ds_so[i].Inv_Org.ToString().Trim() + "' and consignor = '" + ds_so[i].Consignor.ToString().Trim() + "' and sku ='" + ds_so[i].So_Order_Detail[j].Sku.ToString().Trim() + "'";
                                command.CommandType = CommandType.Text;
                                command.CommandText = str_sql;
                                SqldbCenter.ExecuteNonQuery(command);
                                //判断标志是否直接进行收货确认
                                if (ds_so[i].Interface_Type.ToString().Trim() == "1")  //需要直接出库下架
                                {
                                    //首次判断库位是否合法
                                    str_sql = "select count(*) from " + g_usespace + ".mst_location where inv_org = '" + ds_so[i].Inv_Org.ToString().Trim() + "' and location_code = '" + ds_so[i].So_Order_Detail[j].Fact_Location.ToString().Trim() + "' and main_dist <> 'D'";
                                    command1.CommandType = CommandType.Text;
                                    command1.CommandText = str_sql;
                                    i_count = SqldbCenter1.ExecuteScalar(command1);
                                    if (i_count > 0)  //合法，进行入库确认
                                    {
                                        //调用拣货确认的存储过程
                                        command.CommandType = CommandType.StoredProcedure;
                                        command.CommandText = g_usespace + ".SP_SQL_PICK_INTERFACE";
                                        command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                                        command.Parameters["@sp_org"].Value = ds_so[i].Inv_Org.ToString().Trim();
                                        command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                                        command.Parameters["@sp_csgor"].Value = ds_so[i].Consignor.ToString().Trim();
                                        command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
                                        command.Parameters["@sp_so"].Value = ds_so[i].So_No.ToString().Trim();
                                        command.Parameters.Add("@sp_line_no", SqlDbType.Int);
                                        command.Parameters["@sp_line_no"].Value = i_cur_row;
                                        command.Parameters.Add("@sp_loc", SqlDbType.Char, 20);
                                        command.Parameters["@sp_loc"].Value = ds_so[i].So_Order_Detail[j].Fact_Location.ToString().Trim();
                                        command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                                        command.Parameters["@sp_user"].Value = s_user;
                                        command.Parameters.Add("@sp_out", SqlDbType.VarChar, 100);
                                        command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                                        SqldbCenter.ExecuteNonQuery(command);
                                        if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                                        {
                                            str_flag = "-1";
                                            jmexcep.Str_Error_Message = command.Parameters["@sp_out"].Value.ToString().Trim();
                                            command.Parameters.Clear();
                                            break;
                                        }
                                        command.Parameters.Clear();
                                        command.CommandType = CommandType.Text;
                                    }
                                    else  //不合法  
                                    {
                                        str_flag = "-1";
                                        jmexcep.Str_Error_Message = "库位" + ds_so[i].So_Order_Detail[j].Fact_Location.ToString().Trim() + "不存在!";
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                str_flag = "-1";
                                jmexcep.Str_Error_Message = "物料" + ds_so[i].So_Order_Detail[j].Sku.ToString().Trim() + "不存在!";
                                break;
                            }

                        }
                        if (str_flag == "-1")
                        {
                            break;
                        }
                    }
                }
                if (str_flag != "-1")
                {
                    SqldbCenter.Commit();
                    str_flag = "0";
                }
                else
                {
                    SqldbCenter.Rollback();
                }
            }
            catch (System.Exception ee)
            {
                str_flag = "-1";
                jmexcep.Str_Error_Message = ee.Message.ToString().Trim();
                jmexcep.Str_Memo = ee.ToString().Trim();
                SqldbCenter.Rollback();
                //              nvl throw;
            }
            finally
            {
                SqldbCenter.CloseConnection();
                SqldbCenter1.CloseConnection();
            }
        }
        jmexcep.Str_Code = str_flag;
        return jmexcep;
    }

    //江森原料库数据导入
    [WebMethod]
    public string JM_GET_MO(string str_org, string str_consignor, DataSet ds_temp, string s_user)
    {
        string str_sql2 = "";
        DataSet ds_temp2;
        string str_insert;
        int i_line_no = 1;
        string str_ls_middle;

        str_ls_middle = "";
        ds_temp.Tables[0].Columns.Add("so_no");
        ds_temp.Tables[0].Columns.Add("pack_code");
        ds_temp.Tables[0].Columns.Add("order_unit");
        ds_temp.Tables[0].Columns.Add("order_price");
        ds_temp.Tables[0].Columns.Add("convert_modulus");
        ds_temp.Tables[0].Columns.Add("main_sub_flag");

        for (int i = 0; i < ds_temp.Tables[0].Rows.Count; i++)
        {
            // i_count = 0;

            #region SKU
            str_sql2 = "  SELECT * from " + g_usespace + ".mst_sku where inv_org='" + str_org + "' and consignor='" + str_consignor + "' and sku='" + ds_temp.Tables[0].Rows[i]["sku"].ToString().Trim() + "' and main_dist <> 'D'";
            try
            {
                ds_temp2 = Sql_exec_selectsql(str_sql2);
                if (ds_temp2.Tables[0].Rows.Count <= 0) //说明没有记录  
                {
                    continue;
                }
                else
                {
                    ds_temp.Tables[0].Rows[i]["pack_code"] = ds_temp2.Tables[0].Rows[0]["pack_code"].ToString().Trim();
                    ds_temp.Tables[0].Rows[i]["order_unit"] = ds_temp2.Tables[0].Rows[0]["main_unit"].ToString().Trim();
                    ds_temp.Tables[0].Rows[i]["convert_modulus"] = ds_temp2.Tables[0].Rows[0]["convert_modulus"].ToString().Trim();
                    ds_temp.Tables[0].Rows[i]["main_sub_flag"] = ds_temp2.Tables[0].Rows[0]["main_sub_flag"].ToString().Trim();
                    ds_temp.Tables[0].Rows[i]["order_price"] = ds_temp2.Tables[0].Rows[0]["price"].ToString().Trim();
                }
            }
            catch (System.Exception ee)
            {
                return ee.Message.ToString().Trim();
            }
            #endregion
            #region so_type
            if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "出库")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "0";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "退货")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "1";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "寄售")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "2";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "移库")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "3";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "销售")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "4";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "寄存")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "5";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "委外加工")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "6";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "外协加工")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "7";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "三包出库")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "8";
            }
            else if (ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() == "MO出库")
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "0";
            }
            else
            {
                ds_temp.Tables[0].Rows[i]["so_type"] = "0";
            }
            #endregion

            if (ds_temp.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() == "Y")
            {
                ds_temp.Tables[0].Rows[i]["lot_attribute3"] = "保税";
            }
            else if (ds_temp.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() == "y")
            {
                ds_temp.Tables[0].Rows[i]["lot_attribute3"] = "保税";
            }
            else
            {
                ds_temp.Tables[0].Rows[i]["lot_attribute3"] = "非保税";
            }
        }

        DataView DV = ds_temp.Tables[0].DefaultView;
        ds_temp.Tables.Clear();
        DV.Sort = "customer_sale_no,need_time,work_position asc";
        ds_temp.Tables.Add(DV.ToTable());
        #region 获取so_no
        string str_so_no = "", str_no = "", str_return = "", str_sql = "";
        int tmp_page;
        DataSet ds_no;
        if (ds_temp.Tables[0].Rows.Count > 0)
        {
            try
            {
                //判断订单号是否为空
                tmp_page = Sql_get_accountno(str_org, "SO_NO");
                str_no = tmp_page.ToString().PadLeft(4, '0');
                str_return = tmp_page.ToString().PadLeft(8, '0');
                str_sql = "select id_data,memo,substring(convert(char(10),getdate(),112),3,6) as s_date from " + g_usespace + ".Sys_Parameter where inv_org = '" + str_org + "' and id = 8108";
                ds_no = null;
                ds_no = Sql_exec_selectsql(str_sql);
                if (ds_no.Tables[0].Rows.Count > 0)
                {
                    if (ds_no.Tables[0].Rows[0]["id_data"].ToString().Trim() == "1") //说明用特定的格式字母+yymmddxxxx
                    {
                        str_so_no = ds_no.Tables[0].Rows[0]["memo"].ToString().Trim() + ds_no.Tables[0].Rows[0]["s_date"].ToString().Trim() + str_no;
                    }
                    else
                    {
                        str_so_no = "SO" + str_return;
                    }
                }
                else
                {
                    str_so_no = "SO" + str_return;
                }
                ds_temp.Tables[0].Rows[0]["so_no"] = str_so_no;
                if (ds_temp.Tables[0].Rows.Count > 1)
                {
                    for (int i = 0; i < ds_temp.Tables[0].Rows.Count - 1; i++)
                    {
                        if (ds_temp.Tables[0].Rows[i]["customer_sale_no"].ToString().Trim() == ds_temp.Tables[0].Rows[i + 1]["customer_sale_no"].ToString().Trim()
                            && ds_temp.Tables[0].Rows[i]["need_time"].ToString().Trim() == ds_temp.Tables[0].Rows[i + 1]["need_time"].ToString().Trim()
                            && ds_temp.Tables[0].Rows[i]["work_position"].ToString().Trim() == ds_temp.Tables[0].Rows[i + 1]["work_position"].ToString().Trim())
                        {
                            ds_temp.Tables[0].Rows[i + 1]["so_no"] = str_so_no;
                        }
                        else
                        {
                            tmp_page = Sql_get_accountno(str_org, "SO_NO");
                            str_no = tmp_page.ToString().PadLeft(4, '0');
                            str_return = tmp_page.ToString().PadLeft(8, '0');
                            if (ds_no.Tables[0].Rows.Count > 0)
                            {
                                if (ds_no.Tables[0].Rows[0]["id_data"].ToString().Trim() == "1") //说明用特定的格式字母+yymmddxxxx
                                {
                                    str_so_no = ds_no.Tables[0].Rows[0]["memo"].ToString().Trim() + ds_no.Tables[0].Rows[0]["s_date"].ToString().Trim() + str_no;
                                }
                                else
                                {
                                    str_so_no = "SO" + str_return;
                                }
                            }
                            else
                            {
                                str_so_no = "SO" + str_return;
                            }
                            ds_temp.Tables[0].Rows[i + 1]["so_no"] = str_so_no;
                        }
                    }
                }
            }
            catch (System.Exception ee)
            {
                return ee.Message.ToString().Trim();
            }
        }
        #endregion

        if (ds_temp.Tables[0].Rows.Count > 0)
        {
            SqlCommand command;
            command = new SqlCommand();
            SqlDatabaseController SqldbCenter = new SqlDatabaseController();
            try
            {
                SqldbCenter.OpenConnection();
                SqldbCenter.BeginTransaction();
                str_so_no = "";
                for (int i = 0; i < ds_temp.Tables[0].Rows.Count; i++)
                {
                    str_no = ds_temp.Tables[0].Rows[i]["so_no"].ToString().Trim();
                    if (str_so_no.Trim() != str_no.Trim()) //不相等,插入表头
                    {
                        str_insert = "insert into " + g_usespace + ".so_ship_header (inv_org,consignor,so_no,so_day,customer_sale_no,customer_code,original_order_no,so_type," +
                                                                    " so_flag,so_status,main_dist,made_time,maker,rush_flag,cross_flag,so_prior,wave_flag,so_assign,standby_4,standby_5,address,telephone,receiver,customer_name,standby_11,standby_12" +
                                                                    ",project_name,CARRIER_PHONE,need_time,carrier_address,standby_13,standby_14,memo2,memo,eas_no,mechine_no,work_position,line_type,sequence_no,mechine_type)  " +
                                                        " values('" + str_org + "','" + str_consignor + "','" + str_no + "',convert(char(10),getdate(),102),'" + ds_temp.Tables[0].Rows[i]["customer_sale_no"].ToString().Trim() + "'," +
                                                                "'','','" + ds_temp.Tables[0].Rows[i]["so_type"].ToString().Trim() + "','0','0','A', getdate(),'" + s_user + "','','0','0','0','0',1,0,'','','','','',''" +
                                                                ",'" + ds_temp.Tables[0].Rows[i]["project_name"].ToString().Trim() + "','',convert(datetime,'" + ds_temp.Tables[0].Rows[i]["need_time"].ToString().Trim() + "'),'' ,'','','',''" +
                                                                "'','" + ds_temp.Tables[0].Rows[i]["eas_no"].ToString().Trim() + "','" + ds_temp.Tables[0].Rows[i]["mechine_no"].ToString().Trim() + "','" + ds_temp.Tables[0].Rows[i]["work_position"].ToString().Trim() + "','" + ds_temp.Tables[0].Rows[i]["line_type"].ToString().Trim() + "','" + ds_temp.Tables[0].Rows[i]["sequence_no"].ToString().Trim() + "','" + ds_temp.Tables[0].Rows[i]["mechine_type"].ToString().Trim() + "')";
                        command.CommandType = CommandType.Text;
                        command.CommandText = str_insert;
                        SqldbCenter.ExecuteNonQuery(command);
                        i_line_no = 0;
                        str_so_no = str_no;
                    }
                    //插入明细
                    i_line_no++;
                    str_insert = "insert into " + g_usespace + ".so_ship_detail (inv_org,consignor,so_no,so_line_no," +
                                  "  sku,pack_code,order_price,lot_attribute1," +
                                   " lot_attribute2,lot_attribute3,lot_attribute4,lot_attribute5," +
                                   " lot_attribute6,lot_attribute7,lot_attribute8,lot_attribute9," +
                                   " lot_attribute10,lot_attribute11,lot_attribute12,lot_attribute13," +
                                   " lot_attribute14,lot_attribute15,main_dist,made_time," +
                                   " maker,standby_6,standby_7,standby_2," +
                                   " standby_3,so_status,ship_qty_m,ship_qty_s," +
                                   " plan_so_qty_m,plan_so_qty_s,plan_cubage,plan_gross_weight," +
                                   " plan_net_weight,convert_modulus,main_sub_flag)  " +
                                    " values('" + str_org + "','" + str_consignor + "','" + str_no + "'," + i_line_no.ToString().Trim() + "," +
                                    "'" + ds_temp.Tables[0].Rows[i]["sku"].ToString().Trim() + "','" + ds_temp.Tables[0].Rows[i]["pack_code"].ToString().Trim() + "'," + ds_temp.Tables[0].Rows[i]["order_price"].ToString().Trim() + ",''," +
                                    "'','" + ds_temp.Tables[0].Rows[i]["lot_attribute3"].ToString().Trim() + "','',''," +
                                    "'" + ds_temp.Tables[0].Rows[i]["lot_attribute6"].ToString().Trim() + "','','',''," +
                                    "'','','',''," +
                                     "'','','A',getdate()," +
                                        "'" + s_user + "',0,0,''," +
                                          "'','0',0,0," +
                                           "" + ds_temp.Tables[0].Rows[i]["plan_so_qty_m"].ToString().Trim() + "," + ds_temp.Tables[0].Rows[i]["plan_so_qty_m"].ToString().Trim() + ",0,0," +
                                           "0," + ds_temp.Tables[0].Rows[i]["convert_modulus"].ToString().Trim() + ",'" + ds_temp.Tables[0].Rows[i]["main_sub_flag"].ToString().Trim() + "'" +
                                    ")";
                    command.CommandType = CommandType.Text;
                    command.CommandText = str_insert;
                    SqldbCenter.ExecuteNonQuery(command);
                }
                SqldbCenter.Commit();
            }
            catch (System.Exception ee)
            {
                str_ls_middle = ee.Message.ToString().Trim();
                SqldbCenter.Rollback();
            }
            finally
            {
                SqldbCenter.CloseConnection();
            }
        }
        return str_ls_middle;
    }


    //出库单分单存储过程
    [WebMethod]
    public string Sql_exec_proc_sobomsplit_new(string s_org, string s_consignor, string s_eas_no, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_SO_SPLIT_NEW");
        SqlDatabaseController sqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            sqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_eas_no", SqlDbType.Char, 20);
            command.Parameters["@sp_eas_no"].Value = s_eas_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            sqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            sqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }  

    //入库拆单
    [WebMethod]
    public string Sql_exec_proc_asnbomsplit_new(string s_org, string s_consignor, string s_order_no, string s_user)
    {
        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ASN_SPLIT_NEW");
        SqlDatabaseController sqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            sqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_order_no", SqlDbType.Char, 20);
            command.Parameters["@sp_order_no"].Value = s_order_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            sqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }
        }
        catch (System.Exception)
        {
            throw;
        }
        finally
        {
            sqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    //////////////////////////////////////////
    //

    // PC退供应商退货-退单拣货分配计算
    [WebMethod]
    public string Sql_exec_proc_billpickth(string s_inv, string s_consignor, string s_so_no, string s_userid)
    {

        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand("WMS.SP_SQL_BILL_PICK_TH"); // 手持退库入库确认
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_inv;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_wave", SqlDbType.Char, 20);
            command.Parameters["@sp_wave"].Value = "0"; // 0-一单拣货
            command.Parameters.Add("@sp_preparer", SqlDbType.Char, 10);
            command.Parameters["@sp_preparer"].Value = s_userid;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_userid;
            SqldbCenter.ExecuteNonQuery(command);

            //if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            //{
            //    str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            //}




        }
        catch (System.Exception ex)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }

    // PC退供应商退货-整单零数量退货
    [WebMethod]
    public string Sql_exec_proc_picklist0th(string s_inv, string s_consignor, string s_so_no, string s_userid)
    {

        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand("WMS.SP_SQL_PICK_LIST_0TH"); // 手持退库入库确认
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_inv;
            command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
            command.Parameters["@sp_csgor"].Value = s_consignor;
            command.Parameters.Add("@sp_so", SqlDbType.Char, 20);
            command.Parameters["@sp_so"].Value = s_so_no;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_userid;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 255);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
            {
                str_ls_middle = command.Parameters["@sp_out"].Value.ToString().Trim();
            }




        }
        catch (System.Exception ex)
        {
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }


    //////////////////////////////////////////


    // 门店退大仓-保存修改明细数据
    [WebMethod]
    public void SQL_REJ_saveStoreToDCDetail(string s_inv, DataSet ds_asn, string s_userid)
    {
        string s_str;
        int i_count;
        SqlCommand command;
        command = new SqlCommand();
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();

            //判断盘点是否全部确认完成，如果是改状态是3，否则2
            s_str = "select count(*) from wms.asn_rej_detail where  inv_org = '" + s_inv + "' and consignor='" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no='" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "' and asn_line_no='" + ds_asn.Tables[0].Rows[0]["asn_line_no"].ToString().Trim() + "'  ";
            command.CommandText = s_str;
            i_count = SqldbCenter.ExecuteScalar(command);

            if (i_count == 0)
            {
                s_str = "insert into wms.asn_rej_detail(	inv_org,consignor,	asn_no,		asn_line_no,	 " +
                                                        "sku,pack_code,	order_unit," +
                                                        "shelflife_day,	order_qty_m,	order_qty_s," +
                                                        "receive_day,	rec_qty_m,	rec_qty_s, rec_location," +
                                                        "rec_memo,	rej_qty_m,	rej_qty_s,rej_code, rej_memo," +
                                                        "memo,main_dist,made_time,maker)" +
                                "values('" + s_inv + "','" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'," + ds_asn.Tables[0].Rows[0]["asn_line_no"].ToString().Trim() + "," +
                                "'" + ds_asn.Tables[0].Rows[0]["sku"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["pack_code"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["order_unit"].ToString().Trim() + "'," +
                                "'" + ds_asn.Tables[0].Rows[0]["shelflife_day"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["order_qty_m"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["order_qty_s"].ToString().Trim() + "'," +
                                "'" + ds_asn.Tables[0].Rows[0]["receive_day"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rec_qty_m"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rec_qty_s"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rec_location"].ToString().Trim() + "'," +
                                "'" + ds_asn.Tables[0].Rows[0]["rec_memo"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rej_qty_m"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rej_qty_s"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rej_code"].ToString().Trim() + "','" + ds_asn.Tables[0].Rows[0]["rej_memo"].ToString().Trim() + "'," +
                                "'','A',getdate(),'" + s_userid + "')";

            }
            else
            {
                s_str = "update wms.asn_rej_detail set " +
                    "rec_qty_m = '" + ds_asn.Tables[0].Rows[0]["rec_qty_m"].ToString().Trim() + "', " +
                    "rec_qty_s = '" + ds_asn.Tables[0].Rows[0]["rec_qty_s"].ToString().Trim() + "', " +
                    "rej_qty_m = '" + ds_asn.Tables[0].Rows[0]["rej_qty_m"].ToString().Trim() + "', " +
                    "rej_qty_s = '" + ds_asn.Tables[0].Rows[0]["rej_qty_s"].ToString().Trim() + "', " +
                    "rec_location = '" + ds_asn.Tables[0].Rows[0]["rec_location"].ToString().Trim() + "', " +
                    "rec_memo = '" + ds_asn.Tables[0].Rows[0]["rec_memo"].ToString().Trim() + "', " +
                    "rej_code = '" + ds_asn.Tables[0].Rows[0]["rej_code"].ToString().Trim() + "', " +
                    "rej_memo = '" + ds_asn.Tables[0].Rows[0]["rej_memo"].ToString().Trim() + "', " +
                    "update_time = getdate(), " +
                    "updater = '" + s_userid + "'" +

                    " where inv_org ='" + s_inv + "' and consignor ='" + ds_asn.Tables[0].Rows[0]["consignor"].ToString().Trim() + "' and asn_no ='" + ds_asn.Tables[0].Rows[0]["asn_no"].ToString().Trim() + "'" +
                    " and asn_line_no ='" + ds_asn.Tables[0].Rows[0]["asn_line_no"].ToString().Trim() + "'";

            }

            
            command.CommandText = s_str;
            SqldbCenter.ExecuteNonQuery(command);
            SqldbCenter.Commit();
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
    }



    // 门店退大仓-门店退单提交(调用存储过程)
    [WebMethod]
    public string SQL_REJ_confirm(string s_inv,DataSet ds_data, string s_userid)
    {

        string str_ls_middle;
        SqlCommand command;
        command = new SqlCommand("WMS.SP_SQL_RF_REJ"); // 手持退库入库确认
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        str_ls_middle = "";
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            string errMsg = "";
            for (int i = 0; i < ds_data.Tables.Count; i++)
            {
                string inv_org, consignor, asn_no;
                inv_org = ds_data.Tables[0].Rows[i]["inv_org"].ToString().Trim();
                consignor = ds_data.Tables[0].Rows[i]["consignor"].ToString().Trim();
                asn_no = ds_data.Tables[0].Rows[i]["asn_no"].ToString().Trim();

                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
                command.Parameters["@sp_org"].Value = s_inv;
                command.Parameters.Add("@sp_csgor", SqlDbType.Char, 15);
                command.Parameters["@sp_csgor"].Value = consignor;
                command.Parameters.Add("@sp_asn", SqlDbType.Char, 20);
                command.Parameters["@sp_asn"].Value = asn_no;
                command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
                command.Parameters["@sp_user"].Value = s_userid;
                command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
                command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
                SqldbCenter.ExecuteNonQuery(command);
                if (command.Parameters["@sp_out"].Value.ToString().Trim() != "0")
                {
                    str_ls_middle = str_ls_middle + command.Parameters["@sp_out"].Value.ToString().Trim();
                }
                command.Parameters.Clear();
            }

            SqldbCenter.Commit();



        }
        catch (System.Exception ex)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        return str_ls_middle;
    }


    //
    //调用存储过程
    //自动补货指令生成
    [WebMethod]
    public string Sql_exec_proc_repleasum_confirm(string s_org, string s_consignor)
    {
        LogHelpter.AddLog("【自动补货指令生成】存储过程Sql_exec_proc_repleasum_confirm", null, null);

        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_REPLEN_CONFIRM_SUM");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "success")
            {
                LogHelpter.AddLog("1 ", null, null);
                SqldbCenter.Commit();
            }
            else
            {
                LogHelpter.AddLog("2 ", null, null);
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            LogHelpter.AddLog("3 ", null, null);
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        LogHelpter.AddLog("【自动补货指令生成】存储过程Sql_exec_proc_repleasum_confirm调用结束 sp_out = " + command.Parameters["@sp_out"].Value.ToString().Trim(), null, null);
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //生成配送差异单
    [WebMethod]
    public string Sql_exec_proc_adj_add_pscy(string s_org, string s_consignor)
    {
        LogHelpter.AddLog("【生成配送差异单】存储过程SP_SQL_ADJ_ADD_PSCY", null, null);

        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ADJ_ADD_PSCY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "success")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        LogHelpter.AddLog("【生成配送差异单】存储过程SP_SQL_ADJ_ADD_PSCY调用结束 sp_out = " + command.Parameters["@sp_out"].Value.ToString().Trim(), null, null);
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

    //调用存储过程
    //配送差异单确认
    [WebMethod]
    public string Sql_exec_proc_adj_confirm_pscy(string s_org, string s_consignor, string s_user)
    {
        LogHelpter.AddLog("【配送差异单确认】存储过程SP_SQL_ADJ_CONFIRM_PSCY", null, null);

        SqlCommand command;
        command = new SqlCommand(g_usespace + ".SP_SQL_ADJ_CONFIRM_PSCY");
        SqlDatabaseController SqldbCenter = new SqlDatabaseController();
        try
        {
            SqldbCenter.OpenConnection();
            SqldbCenter.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sp_org", SqlDbType.Char, 15);
            command.Parameters["@sp_org"].Value = s_org;
            command.Parameters.Add("@sp_consignor", SqlDbType.Char, 15);
            command.Parameters["@sp_consignor"].Value = s_consignor;
            command.Parameters.Add("@sp_user", SqlDbType.Char, 10);
            command.Parameters["@sp_user"].Value = s_user;
            command.Parameters.Add("@sp_out", SqlDbType.VarChar, 50);
            command.Parameters["@sp_out"].Direction = ParameterDirection.Output;
            SqldbCenter.ExecuteNonQuery(command);
            if (command.Parameters["@sp_out"].Value.ToString().Trim() == "success")
            {
                SqldbCenter.Commit();
            }
            else
            {
                SqldbCenter.Rollback();
            }
        }
        catch (System.Exception)
        {
            SqldbCenter.Rollback();
            throw;
        }
        finally
        {
            SqldbCenter.CloseConnection();
        }
        LogHelpter.AddLog("【配送差异单确认】存储过程SP_SQL_ADJ_CONFIRM_PSCY调用结束 sp_out = " + command.Parameters["@sp_out"].Value.ToString().Trim(), null, null);
        return command.Parameters["@sp_out"].Value.ToString().Trim();
    }

}
